Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Web Services
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Web Services
Output as null
Rodricks george
Ranch Hand
Posts: 97
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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(); */
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Combining JAAS and SOAP in a log on system
Binding XML to Java from SOAP message
Servlet using SAAJ and HTTP Authorization Header
Servlet using SAAJ and HTTP Authorization Header
Webservice Help!
More...