SOAP (Simple Object Access Protocol
2024-09-07 19:04:55
供稿:网友
,欢迎访问网页设计爱好者web开发。
soap (simple object access protocol)
since the release i have been fascinated with this thing called soap, this bubbly new protocol backed by the power of xml is certainly going to make waves in the world of distributed computing. the first thing which comes into our mind is “why the heck we didn’t think of this before?”
soap was originally developed by microsoft, ibm, developmentor and userland software and was then submitted to the internet engineering task force (ietf), who eventually made it an official recommendation. though microsoft camp seem to have played a major role in defining the specification of soap.
the motivation of developing this protocol was the widely used inter-application communication protocols like microsoft’s dcom protocol or java’s rmi or omg’s iiop protocols which have till recent times fulfilled the needs of giving component services over an interconnected network .the richness of these protocols helped them gain a strong hold over distributed computing over controlled environment. almost all these protocols need a smart client able to run the proxies of the server components, moreover, these protocols reveal their limitations when it comes to internet. internet cannot guarantee what kind of client and server will be operating at either end of the connection — it can only guarantee that they are both communicating via http.
soap (simple object access protocol) is a simple solution for interaction of different applications built in different languages and running on different platforms as it uses http as its transport and xml as its payload for sending and receiving messages. its is a lightweight and a loosely coupled protocol for exchange of information in a decentralized and a distributed environment.
what’s so light in soap?
soap relies on http as a transport mechanism to send xml based messages, the messages are packed in what is called a soap envelop and send to the server to process in a request/response fashion. soap unlike proprietary protocols like dcom or rmi does not require strong connection between client and the server and the soap messages are sting based messages passed from the client to server and vice versa in the form of soap envelops.
what makes soap loosely coupled?
most proprietary protocols require the applications of the same breed to be running on both the ends, what if the server is implemented in a different programming language. the ability to access service of a component in a language/location and platform transparent manner reduces the tight coupling between the client and the server. soap enables “incompatible” systems to interoperate.
how does soap message look like and how is it different from a method invoked on a object?
to demonstrate how soap messages are different from method invocation on an component let’s take a look at this activex component, which accepts two integers and returns the total, as a return value would look something like this,
server activex component (mycomponent.mathcomponent)
public function add (num1 as integer, num2 as integer)
add = num1 + num2
end function
the client would create an instance of this component and would invoke the method to get the total.
sub button1_click()
dim objadd as new mycomponent.mathcomponent
dim intresult as integer
intresult = objadd.add(10,20)
end sub
this mycomponent.mathcomponent would get instantiated and serve the request from the client application.
at a higher level a soap request to fulfill this request would look something like this
<add>
<num1>100</num1>
<num2>400</num2>
</add>
in order to ensure that server can correctly identify the methord call it is wrapped up in a soap envelop
<soap:envelop xmlns:soap=”urn:schemas-xmlsoap-org-soap.v1”>
<soap:header></soap:header>
<soap:body>
<add>
<num1>100</num1>
<num2>400</num2>
</add>
<soap:body>
</soap:envelop>
this is just an abstract example to give you a gist of the soap message.
the real soap message will contain more information like the component name and stuff.
this message is sent to a soap listener through http in a request/response fashion.
the soap listener accepts this soap message and does the processing on the component and returns the soap message back for the client.
in the server you will need to implement a soap listener, wsdlgen.exe is a tool which comes with the soap toolkit will create a soap listener and a wsdl (web service description language) file for a given com component. for more information on wsdl visit http://www.msdn.microsoft.com/xml/general/wsdl.asp
oh godddddddd, do i need to marshall and un-marshall the xml messages myself?
the answer is no, the microsoft soap toolkit 2 will take care of the marshaling and un-marshaling of the xml messages behind the scene for you.
the soap toolkit also comes with a set of com component to access soap web services easily, visual basic soap client
sub button1_click()
dim objsoapclient as object
set objsoapclient = createobject("mssoap.soapclient")
objsoapclient.mssoapinit "http://servername/virtualdirectory/wsdlfile.wsdl"
msgbox objsoapclient.add(100,400)
end sub
that’s it, the soap message marshaling and un-marshaling will taken care by the soap client and what you will get is the result.
soap and security
soap as it works on http get the benefits of all the security that are currently available to http, a soap message can pass through the firewall of the web server normally from port 80.
limitations of soap though soap is evolving, and has a number of striking features, which are important in development of, distributed applications but still there are certain things which soap cannot support which i would like to address
soap is a simple protocol: as the name suggests it’s a simple protocol and works on http, we cannot expect all the functionality’s offered by other protocols like dcom or rmi.
soap may turn out to be slower compared to other proprietary protocols as it requires additional xml processing.
still soap fares well in most areas compared to other wire protocol. as per the specifications, soap can also use other transport carrier like smtp to transmit soap messages. still lot of information on this topic in not available.
summary
soap is a compelling and innovative use of available technologies that are not tied to a specific vendor. soap will play a major role in microsoft’s “.net” platform for building webservice. and microsoft is expecting huge revenue to be generated from webservice.