|
Using SOAP广告 Using SOAP Sander Duivestein The Simple Object Access Protocol (SOAP) is a hot topic these days. The technology itself is simple, as shown by Sander Duivestein in this article. But the implications of its use are very exciting. It means that you'll be able to use objects and call methods located on other machines on the Internet. It doesn't matter what language they were written in nor what platform they're running on. SOAP solves all of those problems in one stroke! Right now I'm sitting behind my laptop in a hotel room in London. Each week I face the same trouble of getting back to the Netherlands. I have to call the travel agency that arranges my flight and train tickets. I'm totally dependent on the tight travel schedule given to me. Then I have to contact the hotel to make sure that I have a reservation for the following week. Why do I need to spend time on these issues every week? Isn't there a way that I could make those arrangements myself? Wouldn't it make life easier if there was a Web site that incorporated all of those third party services and offered them to the public? And how would that Web site incorporate all of these third party services? SOAP Microsoft describes SOAP this way: "SOAP is a lightweight protocol for exchange of information in a decentralized, distributed environment. It's an XML-based protocol that consists of three parts: an envelope that defines a framework for describing what's in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses. SOAP can potentially be used in combination with a variety of other protocols." In this article, I want to provide a sample application that uses SOAP to demonstrate how it can be put to practical use. Sample application ? SOAPClient.htm Authors.dll is a COM component that has two classes inside: clsConnectionManager, which manages ADODB connections, and clsRetrieve, which retrieves an ADODB recordset from the database.This example is simple, as it queries the Authors table of the MS SQL Server Pubs database. A client (SOAPclient.htm) contains a HTML form that has three elements. There are two text boxes and a submit button. A user can enter a firstname and/or a lastname and then submit the form by clicking the button. But this form isn't submitted in the same way that most forms are. When the Submit button is pushed, a Javascript function, SendSOAPRequest(), is triggered and the events specified in Table 1 happen. Table 1. The sequence of events that happen when the SendSOAPRequest() is triggered.
The SOAP specification declares that when using SOAP over HTTP, you have to define a HTTP header. This header contains several elements: ? An endpoint—Where the receiver of the SOAP request lives. This endpoint should match the location where you have put this example on the Web server. ? SOAPAction—The SOAPAction describes the purpose of the SOAP call; in this example, the purpose of the call is to invoke the method "GetAuthors" on the remote object "Authors.clsRetrieve." Firewall administrators can also use the SOAPAction attribute to block out certain SOAP calls. ? An indication that the mime-type of the header is XML. Setting the SOAP HTTP header is achieved using the Microsoft XMLHTTPRequest object (see Listings 1 and 2 ). Listing 1. How to set the HTTP header. var objXMLHTTP = _
Listing 2. How to build a SOAP request. function BuildSoapEnvelop()
{ ? A mandatory Envelope The Body element contains the methodname (GetAuthors) and the parameters of the method (FirstName and LastName). Submit the SOAP request objXMLHTTP.send(BuildSoapEnvelop());
'Get the HTTPHeader SOAPAction strSOAPAction =
_ Request.ServerVariables("HTTP_SOAPAction") 'Strip the
SOAPAction into two parts: ' the remote object and the methodname
strObject = _ Left(strSOAPAction, Instr(strSOAPAction, "#") -
1) strMethod = _ Right(strSOAPAction,
_ Len(strSOAPAction) - Instr(strSOAPAction,
"#")) 'Get FirstName and LastName from XML strFirstName =
_ objXML.getElementsByTagName("*").item(4).text strLastName =
_ Build SOAP response 'Query remote component Receive and show SOAP response //Show SOAP Response
Conclusion At this moment, there are several (free!) tools on the market that you can download to help build this kind of application yourself. The first one you should check out is the Microsoft SOAP toolkit on the Microsoft Web site. If you want to know more about SOAP, I suggest you take a look at the following Web sites. They provide a wealth of information: ? http://www.develop.com/soap 如果您希望与本文章的作者或其所在机构,进一步交流,请联系:畅享网 姜小姐 jill.jiang@amteam.org | 021-51096826-112 | 在线联系 |
节能与优化IT 企业CIO过冬良策当前金融危机的影响还在继续漫延,很多企业都在苦寻过冬的良策,在这种情况下,节能与优化技术与产品无疑成为CIO们关注的首要对象,本次选题就是针对节能与优化IT来为CIO们提供过冬的良…… 观08软件并购风潮 议09巨头何处生花2008,似乎注定是不平静的一年。有人说2008是并购年。业内人士表示,在全球软件行业,并购一直是大企业谋求做大做强的捷径之一,包括甲骨文、SAP,微软等全球软件巨头都为了扩大自己…… |
|
|