Sample implementation script and WSDL document
The following document literal web service returns a stock quotation
for a ticker symbol. This limited example returns only a value for
the IBM®
ticker; all other
arguments result in a SOAP fault.
The implementation script is as follows:
The result of running this script is that IBM Product Master does
the following things:
// parse the request document
var doc = new XmlDocument(soapMessage);
// get the ticker parameter
var ticker = parseXMLNode("ibm:ticker");
// we only give out ibm quotes around here...
if (ticker == "IBM") {
out.println("<ibm:getStockQuoteResponse
xmlns:ibm=\"http://ibm.com/wpc/test/stockQuote\">");
out.println("<ibm:response>123.45</ibm:response>");
out.println("</ibm:getStockQuoteResponse)");
}
else {
soapFaultMsg.print("Only quotes for IBM are supported");
}
Method | Sample code |
---|---|
Document literal style |
|
Java™ |
|
WSDL |
|
- Receives a SOAP request from the Axis SOAP stack.
- Validates the request message against the previous schema.
- Starts the web service trigger script. The input variables are:
- operationName = "getStockQuote"- message = "<getStockQuote> <ticker>IBM</ticker> </getStockQuote>"
The trigger script writes the response to theout
writer:- out = "<getStockQuoteResponse> <response>83.76</response> </getStockQuoteResponse>"
- Validates the response against the previous schema.
- Sends the entire SOAP response back to the client through the Axis SOAP stack.