ServersApache SOAP 2.2 Overview Page 11

Apache SOAP 2.2 Overview Page 11

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Processing the SOAP Response

The envelope returned by the server is processed by the Response object. The object contains the SOAP XML stream, and therefore all the characteristics of the response. The stream is processed by the Parameter class methods. By default, the Parameter object processes all the simple data types (e.g., Integer, Long, and String). The calculator service sends back a Long type, and therefore has no special coding.

 //construction of SOAP message ... Response resp = null; try{ resp = call.invoke
(url, soapActionField); } catch( SOAPException e ){ System.err.println("Caught 
SOAPException (" + e.getFaultCode() + "): " + e.getMessage()); System.exit(-1);
 } // Response retrieval. if( !resp.generatedFault() ){ Parameter ret = resp.getReturnValue(); 
Object value = ret.getValue(); System.out.println(value);
 } else{ Fault fault = resp.getFault(); System.err.println("Generated fault: "); 
System.out.println (" Fault Code = " + fault.getFaultCode()); 
System.out.println (" Fault String = " + fault.getFaultString()); } 

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories