G
gabsaga_tata
************** INPUT 1 ************************
<?xml version='1.0'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<SOAP-ENV:Body>
<calculateFibonacci
xmlns='http://namespaces.cafeconleche.org/xmljava/ch3/'
type='xsi
ositiveInteger'>10
</calculateFibonacci>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************** INPUT 2 ********************************
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<calculateFibonacci
xmlns="http://namespaces.cafeconleche.org/xml/ch3/">10
</calculateFibonacci>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
*****************************************************************
The code below produces the results as shown in INPUT 2. What do I need
to add/change to get it to produce the results as shown in INPUT 1?
Please forgive my ignorance 'cause I'm new to webservices.
Thanks.
*************************************************************8
package com.simpaq.soap;
// imports to make a SOAP connection
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPConnection;
// imports for SOAP message
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
// imports to read response
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
public class SOAPRequest
{
public static void main(String args[])
{
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();
//Create objects for the message parts
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
//Populate the body
//Create the main element and namespace
Name name = envelope.createName("calculateFibonacci", "",
"http://namespaces.cafeconleche.org/xml/ch3/");
SOAPElement bodyElement = body.addChildElement(name);
//Add content
bodyElement.addTextNode("10");
//Save the message
message.saveChanges();
//Check the input
System.out.println("\nREQUEST:\n");
message.writeTo(System.out);
System.out.println();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
// JAR files in classpath
/*
/Sun/AppServer/lib/activation.jar
/Sun/AppServer/lib/mail.jar
/Sun/AppServer/lib/saaj-api.jar
/Sun/AppServer/lib/saaj-impl.jar
/Sun/AppServer/lib/commons-logging.jar
/Sun/AppServer/lib/endorsed/xalan.jar
/Sun/AppServer/lib/endorsed/dom.jar
/Tomcat_4_1/common/endorsed/xercesImpl.jar
*/
<?xml version='1.0'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<SOAP-ENV:Body>
<calculateFibonacci
xmlns='http://namespaces.cafeconleche.org/xmljava/ch3/'
type='xsi
</calculateFibonacci>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************** INPUT 2 ********************************
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<calculateFibonacci
xmlns="http://namespaces.cafeconleche.org/xml/ch3/">10
</calculateFibonacci>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
*****************************************************************
The code below produces the results as shown in INPUT 2. What do I need
to add/change to get it to produce the results as shown in INPUT 1?
Please forgive my ignorance 'cause I'm new to webservices.
Thanks.
*************************************************************8
package com.simpaq.soap;
// imports to make a SOAP connection
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPConnection;
// imports for SOAP message
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
// imports to read response
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
public class SOAPRequest
{
public static void main(String args[])
{
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();
//Create objects for the message parts
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
//Populate the body
//Create the main element and namespace
Name name = envelope.createName("calculateFibonacci", "",
"http://namespaces.cafeconleche.org/xml/ch3/");
SOAPElement bodyElement = body.addChildElement(name);
//Add content
bodyElement.addTextNode("10");
//Save the message
message.saveChanges();
//Check the input
System.out.println("\nREQUEST:\n");
message.writeTo(System.out);
System.out.println();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
// JAR files in classpath
/*
/Sun/AppServer/lib/activation.jar
/Sun/AppServer/lib/mail.jar
/Sun/AppServer/lib/saaj-api.jar
/Sun/AppServer/lib/saaj-impl.jar
/Sun/AppServer/lib/commons-logging.jar
/Sun/AppServer/lib/endorsed/xalan.jar
/Sun/AppServer/lib/endorsed/dom.jar
/Tomcat_4_1/common/endorsed/xercesImpl.jar
*/