VB.NET SOAP and Remoting: Part 2
In this article I will explain you about SOAP and VB.NET Remoting.
See Part 1
When we use HTTP, we use the POST request method because with this method, as opposed to the GET method, the size of the HTTP headers is unlimited. We will see two types of headers in HTTP-request headers and response headers. Please refer to the document RFC2616 (Hypertext Transfer Protocol-HTTP 1.1 by R. Fielding et al.) for more details about HTTP implementation details. Listing 23.2 shows an example of an HTTP POST request header. You can add any headers you like to HTTP-for example, in Listing 23.2 SOAPAction is a SOAP-added HTTP header referring to the remote method, UpdateData, to be invoked and its Uniform Resource Locator (URL).
Listing 23.2: HTTP POST Request Header
POST /Order HTTP/1.1
Host: www.mindcracker.com
Content-Type: text/xml
Content-Length: nnnn
SOAPAction: "http://www.mindcracker.com#UpdateData"
Information being sent would be located here.
Listing 23.3 shows a good response-type HTTP header.
Listing 23.3: Good HTTP Response Header
200 OK
Content-Type: text/plain
Content-Length: nnnn
Content goes here.
Listing 23.4 shows a bad HTTP response header.
Listing 23.4: Bad HTTP Response Header
400 Bad Request
Content-Type: text/plain
Content-Length: 0
A SOAP request document without HTTP headers is shown in Listing 23.5.
Listing 23.5: SOAP Request Document Without HTTP Headers
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope"
xsi:schemaLocation=
"http://www.mindcracker.com/schemas/Schema.xsd">
<SOAP-ENV:Header xsi:type="MindcrackerHeader">
<COM:GUID xmlns:COM="http://comobject.northwindtraders.com">
10000000-0000-abcd-0000-000000000001
</COM:GUID>
</SOAP-ENV:Header>
<SOAP-ENV:Body xsi:type="MindcrackerBody">
<OrderUpdate>
<orderID>0</orderID>
<item>89</item>
</OrderUpdate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Listing 23.6 shows a SOAP body schema-the contents of the file http://www.mindcracker.com/schemas/Schema.xsd.
Listing 23.6: Schema.xsd File Contents
<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema"
targetNamespace="http://schemas.xmlsoap.org/soap/envelope"
xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope">
<xsd:complexType name="MindcrackerHeader">
<xsd:element name="GUID" type="string"/>
</xsd:complexType>
<xsd:complexType name="MindcrackerBody">
<xsd:element name="OrderUpdate">
<xsd:complexType>
<element name="orderID" type="integer"/>
<element name="item" type="double"/>
</xsd:complexType>
</xsd:element>
</xsd:complexType>
</xsd:schema>
A successful SOAP response document is shown in Listing 23.7.
Listing 23.7: Successful SOAP Response Document
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope"
xsi:schemaLocation=
"http://www.mindcracker.com/schemas/Schema.xsd">
<SOAP-ENV:Body xsi:type="MindcrackerBody">
<OrderUpdate>
<orderID>09999</orderID>
<return>0</return>
</OrderUpdate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Listing 23.8 shows a faulty SOAP response document. The transaction has failed for the reason noted in the error message.
Listing 23.8: Faulty SOAP Response Document
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope"
xsi:schemaLocation=
"http://www.mindcracker.com/schemas/Schema.xsd">
<SOAP-ENV:Fault>
<SOAP-ENV:faultcode>200</SOAP-ENV:faultcode>
<SOAP-ENV:faultstring>
Must Understand Error
</SOAP-ENV:faultstring>
<SOAP-ENV:detail xsi:type="Fault">
<errorMessage>
The object cannot be found or is not installed.
</errorMessage>
</SOAP-ENV:detail>
</SOAP-ENV:Fault >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Following is an example of a VB.NET SOAP server/client with the UpdateData method declaration:
Public Function OrderUpdateMethod(ByRef OrderID As Integer, ByVal Item As Double) As Integer
End Function
Conclusion
Hope this article would have helped you in understanding SOAP and VB.NET Remoting.