SOAP
Overview
“SOAP Version 1.2 (SOAP) is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. It uses XML technologies to define an extensible messaging framework providing a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics.” - Definition from SOAP Version 1.2 Part 1: Messaging Framework (Second Edition) - W3C Recommendation 27 April 2007
Because of its implementation independence, the SOAP protocol is widely used on the implementation of Web Services.
The SOAP Class
This class represents a SOAP message that, when executed, is sent to the server in a HTTP request. The server response is then received, processed, and the answer made available.
Before creating a instance of SOAP, you may set the following class fields:
The prefix string used to start the request. Note that it uses UTF-8, so unicode characters are not supported. Its default value is:
suffix The suffix string used to finish the request. Its default value is:
debug Changing this value to true enables debug mode, which writes XML parsing information on the debug console (or the default error output when running on JDK). You may also set HttpStream.debugHeader = true. Caution: don’t use this on device because it increases a lot the memory usage.
disableEncoding The SOAP request will ask the server for GZip or ZLib encoded response by default. To disable encoding, set this field to true.
Constructors
To create a new SOAP instance, you must use the following constructor:
Instance Fields
After creating a new SOAP object, you may set some of its following instance fields:
You may change both the mtd and the uri values before executing the request. Although this seems to be pointless, because these values are passed to the constructor.
If the remote method expects any arguments, you must set them using the setParam()
method. However, there are several versions of this method to cover different argument types. Listing all of them would be pointless, so we’ll define a generic type that we’ll refer as , and may be one of the of the following:
int
boolean
double
String
So, whenever a SOAP method is described like setParam( param)
, you can safely assume there are four versions of this method, one for each type listed above. Other type of parameters can be passed using similar methods. Unicode characters are not accepted because the default header uses UTF-8.
SOAP methods for parameters setting:
The only thing left to do now is to execute the request and check the service’s answer:
References
For more details, check out the totalcross.xml.soap package JavaDocs.
Last updated