Using SoapExtension Technology

Source: Internet
Author: User


Compressing text is a procedure this can reduce the size of content representation up to 80%.
This means so compressed text can be stored using the 80% less space than uncompressed text.
It also means the content needs less time to be transferred over a network.
SOAP extensions is a Microsoft asp.net webmethod interception mechanism so can be used to manipulate SOAP REQUESTS/RESPO Nses before they are sent on the wire.
In most cases SOAP requests are much smaller in size than SOAP responses (for example, a large datasets), so we'll only C Ompress SOAP responses in this example.
Reference the Figure File

Improve XML Web Services ' performance by compressing SOAP

This example was that:
The SOAP message was compressed on afterserialize stage (server side) and decompressed on BeforeDeserialize stage (client S Ide
In order to compress our Web service ' s SOAP responses, we need to do two things:
· Compress the "SOAP Response message" After serialization on the server.
· Decompress the SOAP response message before deserialization on the client.
The steps of server side are as following:
· This is the XML Web service This returns a large data.
· Second,on the "server Side", the SOAP response from the ' server is ' compressed in order to reduce its size.
· We Add the ServerSoapExtension.dll assembly as reference and declare the SOAP extension on web.config of the XML Web servi CE: (not necessary)
Then,we turned to the consumer-side SOAP Extension
· Here need a SOAP extension too
· Add the ClientSoapExtension.dll assembly as reference and declare the SOAP extension on the XML Web service Reference of O UR application

Notice:
(1) in the client,we banding "SoapExtension Class to" the "corresponding Reference.cs,which We can find in The Web reference Item in the Client.
And we need to add the code as following:
<remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute ("Http://tempuri.org/GetData", requestnamespace= "http ://tempuri.org/", responsenamespace=" http://tempuri.org/", use= System.Web.Services.Description.SoapBindingUse.Literal, parameterstyle= System.Web.Services.Protocols.SoapParameterStyle.Wrapped), Soapextensionclient.decompresssoap ()]
public string GetData () {
Object[] results = this. Invoke ("GetData", new object[0]);
Return ((String) (Results[0]);
}
When the WebMethod are updated, we need to add this code manually again.
(2) Testing XML:
String test2 = "<?xml version=/" 1.0/"encoding=/" utf-8/"><soap:envelope xmlns:soap=/" http:// schemas.xmlsoap.org/soap/envelope//"xmlns:xsi=/" http://www.w3.org/2001/XMLSchema-instance/"xmlns:xsd=/" http:// www.w3.org/2001/XMLSchema/"><soap:body><getdataresponse xmlns=/" http://tempuri.org//">< Getdataresult>large Data Source Kkk</getdataresult></getdataresponse></soap:body></soap: Envelope> ";

/************************************************************************************
* Qeustion:
(1) Why this code can is complied in the Web.config file;
<!--
<webServices>
<soapExtensionTypes>
<add type= "Testsoapextensionwebservice.compresssoapmessage" priority= "1"

group= "High"/>
</soapExtensionTypes>
</webServices>
-->

If so, we need to configure the SOAP extensions individually as assemblies so we can find them, but we cannot specify different SOAP extension processing for each method within the web.config.
If you want to specify different extension processing for each method, you need to add one at a WebMethod method.
Similarly, at the client we can specify a uniform SOAP extension processing in the app.config. However, if you want to specify different extension processing for each method, you need to add the previous one to the reference of the specific WebMethod method.
It is best that we configure the SOAP extensions to be unified into an assembly that is easy to publish and manage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.