File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Axis2 SAAJ API conflict with Java6 SAAJ - UnknownHostException on call()   Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 SAAJ API conflict with Java6 SAAJ - UnknownHostException on call()   " Watch "Axis2 SAAJ API conflict with Java6 SAAJ - UnknownHostException on call()   " New topic
Author

Axis2 SAAJ API conflict with Java6 SAAJ - UnknownHostException on call()

sheetal sharma
Greenhorn

Joined: Nov 06, 2008
Posts: 1
Hi All,

I have a java program that sends XML file as a SOAP request using proxy and in turns retrieves an XML response from a server. I am using java6 to compile and run this program and it works fine.


Now I intend to make this as a web service using Axis2 version 1.4.1 and as a first step I included Axis2 libraries to my projects classpath in eclipse 3.3. Now I again ran the same program and it failed. Here is the stack trace.




--------------------------------------------------------------------------------

Exception in thread "main" javax.xml.soap.SOAPException: xxxxx.com


at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:194)


at org.apache.axis2.saaj.SOAPConnectionImpl.call(SOAPConnectionImpl.java:130)


at ActivityWebService.SendSoapMessage(ActivityWebService.java:252)


at ActivityWebService.main(ActivityWebService.java:143)


Caused by: org.apache.axis2.AxisFault: xxxxx.com


at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)


at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)


at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)


at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371)


at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209)


at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)


at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)


at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)


at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)


at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:188)


... 3 more


Caused by: java.net.UnknownHostException: xxxxx.com


at java.net.PlainSocketImpl.connect(Unknown Source)


at java.net.SocksSocketImpl.connect(Unknown Source)


at java.net.Socket.connect(Unknown Source)


at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)


at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)


at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknown Source)


at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:82)


at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1.doit(ControllerThreadSocketFactory.java:91)


at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$SocketTask.run(ControllerThreadSocketFactory.java:158)


at java.lang.Thread.run(Unknown Source)




--------------------------------------------------------------------------------

On further investigation I found that this is being caused by axis2-saaj-1.4.1.jar as it conflicts with Java6. If I remove axis2-saaj-1.4.1.jar from my classpath I am able to run the same program.


Is my analysis valid? If so, Is it okay to use java's SAAJ api instead of Axis2's SAAJ api? Do you see any issues in this in longer run?


The exception is thrown at this code line


SOAPMessage response = SOAPConn.call(message, endpoint);


Here is few code snippets from my program.



// Setting up proxies


System.+setProperty+("proxySet","true");


System.+setProperty+("proxyHost","abc-def-xyz.com");


System.+setProperty+("proxyPort","8080");


// Getting inputs from command line and Authenticating.


String SOAPUrl = args[0];


String xmlFile2Send = args[1];


final String authUser = args[2];


final String authPassword = args[3];


Authenticator.+setDefault+(


new Authenticator() {


public PasswordAuthentication getPasswordAuthentication() {


return new PasswordAuthentication(


authUser, authPassword.toCharArray());


}


}


);



System.+setProperty+("http.proxyUser", authUser);


System.+setProperty+("http.proxyPassword", authPassword);


// Sending XML and processing response



private static void SendSoapMessage(String SOAPURL, String SOAPAction, String sXML) throws Exception


{


//context


SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.+newInstance+();


SOAPConnection SOAPConn = soapConnectionFactory.createConnection();


MessageFactory factory = MessageFactory.+newInstance+();



SOAPMessage message = factory.createMessage();


MimeHeaders headers = message.getMimeHeaders();



// SOAP11


headers.addHeader("SOAPAction", "\"http://tempuri.org/" + SOAPAction + "\"");


SOAPPart soapPart = message.getSOAPPart();


StringReader srXml = new StringReader(sXML);


StreamSource ssXML = new StreamSource (srXml);


soapPart.setContent(ssXML);



message.saveChanges();


message.writeTo(System.+out+);



// call the SOAP service


URL endpoint = new URL(SOAPURL);


SOAPMessage response = SOAPConn.call(message, endpoint);



SOAPConn.close();


// Debug - Can remove this line


response.writeTo(+fos+); // DEBUG


// extract body from the response


SOAPBody soapBody = response.getSOAPBody();


// check for SOAP fault


if (soapBody.hasFault())


throw new Exception("SOAP Fault - " +


soapBody.getFault().getFaultString());


// extract the Result tag element


NodeList lstResult = soapBody.getElementsByTagName("TagNameTest");



SOAPElement elResult = (SOAPElement)lstResult.item(0);


String sResult = elResult.getValue();


System.out.println("Result: " + sResult);


}


Appreciate your help and guidance.


Thanks,


SMS
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis2 SAAJ API conflict with Java6 SAAJ - UnknownHostException on call()