This week's book giveaway is in the
General Computing
forum.
We're giving away four copies of
Arduino in Action
and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Web Services
Author
Output as null
Rodricks george
Ranch Hand
Joined: Sep 10, 2006
Posts: 97
posted
Mar 12, 2008 23:02:00
0
Hi,
I have created a jws
public class Calculator { public int add(int i1, int i2) { return i1 + i2; } public int subtract(int i1, int i2) { return i1 - i2; } }
if i run this client i am getting result as null. Plese give some idea.
String arg1 = "20"; String arg2 = "20"; String operation = "add"; // could also be "subtract" String urn = "CalculatorService"; String destination = "http://localhost:8080/axis/Calculator.jws"; try { // First create the connection SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnFactory.createConnection(); // Next, create the actual message MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); // This method demonstrates how to set HTTP and SOAP headers. // setOptionalHeaders(message, envelope); // Create and populate the body SOAPBody body = envelope.getBody(); // Create the main element and namespace SOAPElement bodyElement = body.addChildElement( envelope.createName(operation, "ns1", "urn:"+urn)); // Add parameters bodyElement.addChildElement("in0").addTextNode(arg1); bodyElement.addChildElement("in1").addTextNode(arg2); // Save the message message.saveChanges(); // Check the input System.out.println("\nRequest:\n"); message.writeTo(System.out); System.out.println(); // Send the message and get the reply SOAPMessage reply = connection.call(message, destination); // Retrieve the result - no error checking is done: BAD! soapPart = reply.getSOAPPart(); envelope = soapPart.getEnvelope(); body = envelope.getBody(); Iterator iter = body.getChildElements(); Node resultOuter = ((Node) iter.next()).getFirstChild(); Node result = resultOuter.getFirstChild(); // Check the output /* System.out.println("\nResponse:\n"); // Create the transformer TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); // Extract the content of the reply Source sourceContent = reply.getSOAPPart().getContent(); // Set the output for the transformation StreamResult result = new StreamResult(System.out); transformer.transform(sourceContent, result); System.out.println(); */
I agree. Here's the link:
http://aspose.com/file-tools
subject: Output as null
Similar Threads
Binding XML to Java from SOAP message
Webservice Help!
Servlet using SAAJ and HTTP Authorization Header
Combining JAAS and SOAP in a log on system
Servlet using SAAJ and HTTP Authorization Header
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter