• 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

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
It's exactly the same and completely different as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic