Web Services Interoperability and SOAP 来源: 时间:2002-09-13 13:13 作者:AMTeam.org Web Services Interoperability and SOAP
May 1, 2001 Summary: This article presents an overview and practical introduction to current interoperability issues relating to RPC calls with SOAP. Three sources of interop problems are discussed: HTTP problems, XML issues, and SOAP discontinuities. (7 printed pages) Introduction At the heart of this vision is the concept of interoperability ("interop" for short), or the capacity of disparate systems to communicate and to share data seamlessly. This is the goal of Web Services. A Web Service is a programmable application logic accessible using standard Internet protocols, or to put it another way, the implementation of Web-supported standards for transparent machine-to-machine and application-to-application communication. A number of Web Services technologies, such as SOAP (Simple Object Access Protocol), WSDL (Web Service Description Language), and HTTP (HyperText Transfer Protocol), are now used to pass messages between machines. These messages can range widely in complexity, from method calls to purchase order submissions. One common, higher-level function of a Web Service is to implement RPC-style communication (remote procedure call, whereby a program on one computer executes a program on another). This article presents a practical introduction to common interop issues seen today in RPC-style communication using SOAP. Messaging with SOAP, WSDL, and other protocols may be the subject of future articles. What Is SOAP? Here is a typical SOAP request (including the HTTP headers) for an RPC method call named EchoString, which takes a string as a parameter: POST /test/simple.asmx HTTP/1.1 <?xml version="1.0"
encoding="utf-8"?> As you can see, the method name is encoded as the XML: <tns:echoString>, and the string parameter is encoded as <inputString>. The C# method that this represents looks like this: public String echoString(String inputString); And here is the response from the server: HTTP/1.1 200 OK <?xml version="1.0"
encoding="utf-8"?> The rules for serializing the string datatype, as well as the method call shape, are defined in SOAP 1.1, sections 5 and 7 (www.w3.org/tr/soap). Common Interop Problems HTTP problems Transport Problems A simple example of an HTTP interop problem involves the use of SOAPAction. SOAPAction is an HTTP header that must be present in SOAP messages over HTTP. This header can be assigned many different values, such as: SOAPAction: "http://tempuri.org/" The value of SOAPAction must be quoted, although completely null is allowed: SOAPAction: The problem here is this: If a server requires this null-value SOAPAction, some clients will be unable to comply, for not all HTTP client APIs have a way of setting a null HTTP header value. Two possible solutions are: fix the client APIs, and/or be certain servers don't require a null-value SOAPAction. In general, the only way to avoid problems such as this is to ensure that the HTTP API used is one that is robust and already known to work across the Web. Even so, such issues can still arise, and testing may be the only way to discover them. XML Problems An interesting example of an interop issue involving both XML parsing and HTTP transports relates to the Byte Order Mark, or BOM. When sending data over HTTP, you can specify the encoding of the data, such as UTF-16 or UTF-8, in the Content-Type header. You can also indicate the encoding of a piece of XML by inserting a set of bytes that specify the encoding used. When sending UTF-16, the BOM is needed, even if the encoding is present in the Content-Type header (to indicate big-endian or little-endian), but for UTF-8 it is unnecessary. For instance: HTTP/1.1 200 OK n++<?xml version="1.0"
encoding="utf-8"?> The first three characters here are hex for the Byte Order Mark indicating UTF-8, but as you can see, the Content-Type also stated this. Some implementations send the BOM for UTF-8, even though they don't need to. Others are unable to process XML with any BOM. The solution here is to avoid sending it unless needed, and to correctly handle it. The correct handling of BOM is essential in processing UTF-16 messages, as BOM is required in this case. Although there is no single way to resolve such issues ahead of time, the best solution once issues are recognized is to refer to the actual specifications (usually found at the W3C) that describe the standards; then apply those specifications as the arbiter of any problem. SOAP Problems SOAP itself is relatively simple. It requires that messages be put into an envelope, with the meat of the message inside a body element. SOAP makes optional such items as headers, and gives leeway as to what can go into the body element. Here is an example of a simple SOAP message that most stacks wouldn't have a problem interoperating with: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> This isn't very interesting, but SOAP also provides for a way to encode common data types (see Section 5 of the SOAP specifications), and it further describes how to encode RPC method calls. As you may remember from the earlier example, method names become child tags of the body, and arguments become child tags of the method name. Yet even without this extra complexity, a variety of interesting interop problems can be found. For instance, SOAP specifications state that if you receive a SOAP header with a mustUnderstand attribute set to "1," you must understand it, or fault. Many implementations didn't do this at first. Here is an example of a mustUnderstand header: HTTP/1.1 200 OK n++<?xml version="1.0"
encoding="utf-8"?> This sample is one of the many issues discovered through SOAP interoperability testing. More examples of interop problems that we have seen can be viewed in the archives of http://groups.yahoo.com/group/soapbuilders. Overall, the work done on this list and across the world to make sure that SOAP interoperates when implementing RPC-style communications has been an outstanding success. From May 8th through May 10th, in Las Vegas at Networld+Interop, many in the SOAP community will be gathering to demonstrate this success. If you have a SOAP stack, or are just curious, come by and check out the demos. Also, much of the XML Web Services discussion and testing has been taking place at http://groups.yahoo.com/group/soapbuilders, http://www.mssoapinterop.org/, and http://www.xmethods.net/ilab/. These sites contain links to many endpoints for interop testing. Anyone building a SOAP stack is encouraged to read the archive and participate in the interop testing. Other recommended sites: The Future |
关键词:
|
相关文章 |