Send attachments (such as pictures, etc.) using WSE2.0)

zhaozj2021-02-16  54

DIME using WSE2.0 can send attachments.

1. The server side is to enter and reference to Microsoft.Web.Services2.dll and the client.

2, use configuration edtion to configure Web.config for the web service, open the Configuration EDTION, select all items in the General tag, then select Save, prompt to save as a config file, save this file after saving, copy the related content inside Web.config

3, add a method to the AdvanceDservice.asmx file of the web server:

///

/// transmission using DIME attachment /// [WebMethod] public string GetAttachment () {SoapContext myContext = ResponseSoapContext.Current; string filePath = Server.MapPath ( "Demo / tmpPic1.jpg" ); DimeAttachment DimeImage = New Dimeattachment ("Image / JPEG", TypeFormat.mediatype, FilePath; DimeImage.Id = "TMPPIC1.JPG";

// Add the new DimeAtTachment object to the SOAPCONTEXT object, MyContext.attachments.Add (DimeImage); Return Filepath;

}

4. Add a web reference to the client, such as: Services, which will automatically generate an agent class AdvanceDServiceWse.

Always ending WSE.

5, add the following code at the client:

private void Page_Load (object sender, System.EventArgs e) {AdvancedServiceWse asv = new AdvancedServiceWse (); try {myString = asv.GetAttachment ();} catch (Exception ex) {Response.Output.Write (call failed!);

return;} Bitmap myImage = new Bitmap (asv.ResponseSoapContext.Attachments [0] .Stream); MemoryStream mStream = new MemoryStream (); myImage.Save (mStream, ImageFormat.Jpeg); myImage.Dispose ();

Response.clearContent (); response.contenttype = "image / jpeg"; response.binarywrite (MSPONSE.EEND ();}

This will show the pictures sent from the web service.

转载请注明原文地址:https://www.9cbs.com/read-19774.html

New Post(0)