1. Soap: Simple Object Access Protocol ^ {symbolic optimal assembly program }.
2.1.http-Get
2.2.http-post
Soap
Definition:Soap is a lightweight protocol used to exchange structured information in a distributed and distributed environment. Soap uses XML technology to define an extensible message processing framework. It provides a message structure that can be exchanged through multiple underlying protocols. The design idea of this framework is to be independent from any specific programming model and the semantics of other specific implementations.
Features:
This definition does reflect the current purpose of soap. Soap defines a method to transmit XML messages from point A to point B (see figure 1 ). Therefore, it provides a Message Processing Framework Based on XML and has the following features:
1) scalability,
2) It can be used through multiple underlying network protocols
3) independent from the programming model.
The three features are discussed in detail below.
Simple SOAP Message Processing
1: Soap scalability is the key. When this acronym also represents some meaning, "S" means "simple ". If we have learned one thing from the web, simplicity is always more important than efficiency and pure technology. Therefore, the key to the success or failure of interoperability lies in the need for simplicity. Simplicity remains one of the main design goals of soap. This is an example of soap's lack of many features of distributed systems (such as security, routing, and reliability ). Soap defines a communication framework that allows you to add these features over time in the form of hierarchical scaling. Microsoft, IBM, and other software vendors are actively developing a universal suite of soap extensions that will join the features most developers expect. This plan is known as the Global XML Web Service structure (gxa). Microsoft has released a reference implementation for several gxa specifications and named it Web Services enhancements 1.0 SP1 for Microsoft.. Net (WSE ).
2: Soap can be used on any transmission protocol (such as TCP, HTTP, SMTP, or even MSMQ) (see figure 1 ). However, to maintain interoperability, some standard protocol bindings need to be defined to draft rules for each environment. The SOAP specification provides a flexible framework for defining any Protocol binding. Because HTTP is widely used, it now provides an explicit binding for HTTP.
3: SOAP allows any programming model and does not depend on RPC. Most developers immediately equivalent soap to RPC calls to distributed objects (Because soap was initially about "access objects"), but in fact, the basic soap model is closer to traditional message processing systems, such as MSMQ. Soap defines a model to process individual one-way messages. You can combine multiple messages into one overall message exchange. Figure 1 illustrates a simple one-way message in which the sender does not receive a response. However, the receiver can send a response to the sender (see figure 2 ). SOAP allows the use of any number of message exchange modes (MEP), and request/response is only one of them. Other examples include requirements/responses (opposite to requests/responses), notifications, and long-running point-to-point conversations.
Request/response message exchange mode
Developers often confuse requests/responses with RPC, but in fact there is a big difference between the two. RPC uses request/response, but the request/response is not necessarily RPC. RPC is a programming model that allows developers to call methods. RPC needs to convert the method signature to a SOAP message. In view of the wide application of RPC, soap drafted a protocol to use RPC for soap.
With these three main features, the SOAP Message Processing framework facilitates the exchange of XML messages in heterogeneous environments. in such environments, interoperability has long been a great challenge.
HTTP
HTTP-GET
Definition:HTTP-GET is a type of Hypertext Transfer protocol.
Features:
. Add data to URL
. Use a question mark ("?") The end of the URL and the beginning of the data.
. Each data element is displayed in the form of name/value (name/value) (separated ).
. Use a semicolon (";") to distinguish multiple data elements.
HTTP-POST
Definition:HTTP-POST is a type of Hypertext Transfer protocol.
Features:
. Include data in the HTTP body.
. Similarly, the data element is in the form of name/value (name/value) (separated ).
. However, each data element occupies one row of the subject.
HTTP and soap
HTTP advantages (reference ):
. The ability to easily create the right HTTP-GET and HTTP-POST messages when facing customers who are not using soap is the best choice for HTTP-GET and HTTP-POST.
. Responding to messages from HTTP-GET and HTTP-POST does not require complex XML processing. The response includes XML, but it has a simple framework and can easily handle the response using general technologies. These features make HTTP-GET and HTTP-POST useful for changing exceptions for platforms that do not support xml.
. HTTP-GET and HTTP-POST messages are simpler than soap messages. This will improve the overall performance.
Disadvantages (reference ):
. HTML cannot be used to call methods with complex data types as parameters in XML Web Service.
. You can call the method in XML Web Service to return values of complex data types, but the response will only include the names/Values in various regions of complex data types, and the returned values have no structure. You must manually extract the data to the WSDL file.
. In HTTP, you cannot use reference to transmit parameters.
. Using HTTP to communicate with XML Web Services is not an agreed-to industrial standard technology. Although HTTP works normally with XML Web Service in ASP. NET web application, it is not guaranteed to work normally in other environments.
Note:
Cookie is dependent on the HTTP transmission protocol. If soap can read the cookie generated by HTTP, this is impossible. Soap can only process the Cookie obtained by the cookie library each time.
Soap is slower than http. If not necessary, do not transmit big data blocks.
Soap must be a W3C XML file. in C #, stream STM = Req. getrequeststream () is sent in httpwebrequest ();
Doc. Save (STM );
To send the message, if you need to get:
Webresponse resp = Req. getresponse ();
STM = resp. getresponsestream ();
Streamreader r = new streamreader (STM );
Sending a soap, in Web programming, is based on the HTTP-POST method, PHP sends a POST request to the following function:
<? PHP
Function httppostrequest ($ host, $ path, $ arrpostvars, $ Port = 80, $ Referer = ""){
$ Arrencodedpairs = array ();
$ Res = "";
Foreach ($ arrpostvars as $ Var => $ value)
$ Arrencodedpairs [] = rawurlencode ($ var). "=". rawurlencode ($ value );
$ Postdata = implode ("&", $ arrencodedpairs );
$ Request = "post $ path http/1.1 \ n ".
"Host: $ host \ n ".
($ Referer )? "Referer: $ Referer \ n ":"").
"Content-Type: Application/X-WWW-form-urlencoded \ n ".
"Content-Length:". strlen ($ postdata). "\ n ".
"Connection: Close \ n ".
$ Postdata. "\ n ";
If ($ fp = fsockopen ($ host, $ port )){
If (fputs ($ FP, $ request )){
While (! Feof ($ FP )){
$ Res. = fgets ($ FP, 128 );
}
Fclose ($ FP );
Return $ res;
}
}
}
?>
Echo (httppostrequest ('s', '/myps/webs. asmx/islogin', array ("input" => "my input"), 81 ));
HTTP is a stateless protocol, for example:
Private string myname;
[Webmethod]
Public void setmyname (string input ){
This. myname = input;
}
[Webmethod]
Public String getmyname (){
Return this. myname;
}
If you use
Ws_app.setmyname ("cookies ");
Returnint. Text = ws_app.getmyname ();
The value cannot be obtained. For details, refer:
[Webmethod (enablesession = true, messagename = "setsession")]
Public void setsession (string input ){
Context. session ["Oop"] = input;
}
[Webmethod (enablesession = true, description = "getsession", messagename = "getsession")]
Public String getsession (){
Return context. session ["Oop"]. tostring ();
}
To be familiar with Web Services, the above knowledge must be properly understood.