Technical Details:
Sample Soap Message
The following message searches for microsoft.com in the domain
registry:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<mns:ProcessSRL xmlns:mns="http://www.SoapClient.com/xml/SQLDataSoap.xsd">
<SRLFile xsi:type="xsd:string">/xml/whois.sri</SRLFile>
<RequestName xsi:type="xsd:string">whois</RequestName>
<key xsi:type="string">microsoft.com</key>
</mns:ProcessSRL>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Dim MyAgent As SoapAgent
Set MyAgent = New SoapAgent
MyAgent.AddParameter "SRLFile", "/xml/WHOIS.SRI", ""
MyAgent.AddParameter "RequestName", "Whois", ""
MyAgent.AddParameter "key", "microsoft.com", ""
'Execute the method
MyAgent.ExecuteMethod "http://soapclient.com/xml/SQLDataSOAP.wsdl", "ProcessSRL"
'show me the result!
MsgBox MyAgent.GetResponse("return")
Sample VB Code (MS SOAP 2.0)
Dim Serializer As SoapSerializer
Dim Connector As SoapConnector
Dim Reader As SoapReader
Set Connector = New HttpConnector
Connector.Property("EndPointURL") = "http://soapclient.com/xml/SQLDataSoap.WSDL"
Connector.Connect
Connector.Property("SoapAction") = "/SQLDataSRL"
Connector.BeginMessage 'Nothing
Set Serializer = New SoapSerializer
Serializer.Init Connector.InputStream
Serializer.startEnvelope "SOAP-ENV", "http://schemas.xmlsoap.org/soap/encoding/"
Serializer.startBody
Serializer.startElement "ProcessSRL", "http://www.SoapClient.com/xml/SQLDataSoap.xsd", "mns"
Serializer.startElement "SRLFile"
Serializer.writeString "/xml/whois.sri"
Serializer.endElement
Serializer.startElement "RequestName"
Serializer.writeString "whois"
Serializer.endElement
Serializer.startElement "key"
Serializer.writeString "microsoft.com"
Serializer.endElement
Serializer.endElement
Serializer.endBody
Serializer.endEnvelope
Connector.EndMessage
Set Reader = New SoapReader
Reader.Load Connector.OutputStream
If Not Reader.Fault Is Nothing Then
MsgBox Reader.faultstring.Text, vbExclamation
Else
MsgBox Reader.DOM.xml
End If
Sample Java Code: (Contributed by Richard Ford of Cenetech
)
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
/*
* Trivial Whois SOAP Service Java Client
* Use entirely at your own risk. Author assumes no liabilities.
* Richard Ford rford@cenetec.com
*/
public class Whois {
public static void main (String[] args) throws Exception {
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
URL url = new URL("http://www.SoapClient.com/xml/SQLDataSoap.WSDL");
// Build the call.
Call call = new Call ();
call.setTargetObjectURI("http://www.SoapClient.com/xml/SQLDataSoap.xsd");
call.setMethodName ("ProcessSRL");
call.setEncodingStyleURI(encodingStyleURI);
Vector params = new Vector ();
params.addElement (new Parameter("symbol",
String.class, symbol,
null));
params.addElement (new Parameter("SRLFile",
String.class,"/xml/WHOIS.SRI", null));
params.addElement (new Parameter("RequestName",
String.class,"Whois", null));
params.addElement (new Parameter("key",
String.class,"microsoft.com", null));
call.setParams (params);
Response resp = call.invoke ( url, "ProcessSRL"
);
// Check the response.
if (resp.generatedFault ()) {
Fault fault = resp.getFault ();
System.out.println ("The call failed:
");
System.out.println (" Fault Code
= " + fault.getFaultCode ());
System.out.println (" Fault
String = " + fault.getFaultString
());
} else {
Parameter result = resp.getReturnValue ();
System.out.println (result.getValue ());
}
}
}
Tested using Apache SOAP 2.2, Java 1.3.1
|