Hi friends,
I am developing one webservice through SAAJ. I want to know, is the request and response are
SOAP message or not? But i donot know how to pass the complex type parameter through SAAJ. Below is the code that i am using.
import goog.*;
import javax.xml.soap.*;
import java.net.*;
import javax.activation.*;
public class RmiTypeClient extends goog.Pressures{
public RmiTypeClient(
String value){
super(value);
}
public static void main(String args[]){
try{
RmiTypeClient r1 = new RmiTypeClient("gramPressurePersqcm");
RmiTypeClient r2 = new RmiTypeClient("inchH2O60F");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPBody body = message.getSOAPBody();
SOAPFactory soapFactory = SOAPFactory.newInstance();
Name operation = soapFactory.createName("changePressureUnit","webservicex","http://www.webservicex.net"); //changePressureUnit is the method name
SOAPBodyElement operElement = body.addBodyElement(operation);
Name param1 = soapFactory.createName("param1");
SOAPElement paramElement1 = operElement.addChildElement(param1);
paramElement1.addTextNode("12.0"); // this is first parameter
Name param2 = soapFactory.createName("param2");
SOAPElement paramElement2 = operElement.addChildElement(param2);
paramElement2.addTextNode("r1"); // this is second parameter, r1 is the complex type parameter of "RmiTypeClient" class. but i donot know how to pass it here??
Name param3 = soapFactory.createName("param3");
SOAPElement paramElement3 = operElement.addChildElement(param3);
paramElement3.addTextNode("r2"); // this is third parameter, r2 is the complex type parameter of "RmiTypeClient" class, but i donot know how to pass it here??
SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
SOAPConnection con = conFactory.createConnection();
URL serviceUrl = new URL("http://www.webservicex.net/CovertPressure.asmx?WSDL");
SOAPMessage response = con.call(message,serviceUrl);
SOAPBody resBody = response.getSOAPBody();
if(resBody.hasFault()){
SOAPFault fault = resBody.getFault();
System.out.println("Error occured at: "+fault.getFaultCode()+ " side coding");
System.out.println("reason: "+fault.getFaultString());
}else{
System.out.println("this is soap message");
}
}catch(Exception e){
System.out.println(e);
}
}
}
Please help me to resolve it.
Thanks in advance.