Skip to main content
Skip table of contents

Using HTTP GET and JSON

In addition to accessing Web services by exchanging SOAP envelopes using the HTTP POST protocol, SOAPam Server also allows the use of the HTTP GET protocol to access Web services. Using the HTTP GET protocol can be more convenient when developing client applications on platforms that don't support SOAP or XML. When accessing a service via HTTP GET there are some considerations and restrictions:

  • The Web service method parameters are supplied as query string arguments and therefore must be simple data types.
  • All method parameters are considered optional. This allows methods with complex types to be invoked using HTTP GET, however it is assumed that the Service Definition will provide suitable values for the omitted parameters using initializers.
  • The method name provided in the URL is case sensitive and must be provided exactly as specified in the Service Definition.
  • There is currently no mechanism to perform Client Transaction Control using the HTTP GET protocol.

Web service methods can be invoked by simply appending the method name to the Web service endpoint URL and providing the method parameters as query string arguments. For example, the Echo String sample service that is provided with SOAPam Server can be accessed at the endpoint URL:

http://host:port/services/samples/echostring/echostring

The service's echoString method has the following signature:

return = echoString(inputString)

Using this information the following URL can be used to invoke the echoString method and echo the string "hello world!":

http://host:port/services/samples/echostring/echostring/echoString?inputString=hello world!

Accessing this URL from a browser (which uses the HTTP GET protocol) yields the following result:

XML
<echoStringResponse xmlns="http://soapam.nuwave-tech.com/services/echostring/echostring/">
  <return>hello world!</return>
</echoStringResponse>

Note that although the response from an HTTP GET request is an XML stream, it is not wrapped in a SOAP envelope. This makes it somewhat easier to parse the response. SOAPam Server can also return the response as a JavaScript Object Notation (JSON) stream. Appending the argument "jsonresult=1" to the query string instructs SOAPam Server that a JSON result is desired. For example, the URL:

http://host:port/services/samples/echostring/echostring/echoString?inputString=hello world!&jsonresult=1

Yields the following result:

JS
{ 'return': 'hello world!' }

The JSON result can be parsed into JavaScript objects using the eval function. The following JavaScript fragment parses and displays the result:

JS
var resultObject = eval('(' + jsonresultstream + ')');
alert(resultObject.return);

 

 

 

 

 

 

 

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.