Use WSE (Web Services Enhancements) to transfer the server's files to the client

zhaozj2021-02-16  62

For example, now there is an attachment to the site B now, we can use WSE to pass. This method of attachment is to take:: writing webmethod webservice in the file server service1.asmx [WebMethod] public void GetAttachment () {// Get response message SoapContext SoapContext myContext = HttpSoapContext.ResponseContext; // string that represents the annex File name and path. String filepath = @ "c: / my documents / 1.txt";

// Use the file name to create a new DIME attachment, / / ​​and specify attachment encoding via MIME media type //. DimeAtTachment DimeImage = New DimeAtTachment ("Text / XML", TypeFormatenum.mediatype, filepath; // Specify the ID attribute recorded to the DIME record. DimeImage.id = "1.txt";

// Add the new DimeAtTachment object to the SOAPCONTEXT object. MyContext.attachments.add (DimeImage);

} Download Attachment on the client's Web site and write to a new file: private void Downattachment () {// service1wse: Microsoft.Web.Services.WebserviceClientProtocol here Service1 inherits WSE in the class service1WSE sw = new service1wse () ;/ 得 = = = = 得;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BYTE [Length]; // written to the stream of the attachment in str.read (attdu, 0, length);

// Create a new file fileInfo fi = new fileInfo (@ "C: /" sw.responseSoapContext.attachments [0] .id); filestream fs = fi.create (); // write Byte into a new file. Write (attdu, 0, length); fs.flush (); fs.close ();} Note: SystemTem.Web sections in WebService sites and client Website sites:

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

New Post(0)