• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Making a webservice call using axis2

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing a client for a web service that is already existing. I got axis2 and created the code form the WSDL2Java from the web service's WSDL. I set all of the objects but now do not know how to make the call to the service.

The documentation provided from the web service vendor is in ASP.NET, however, I'm using Java. I was able to follow their example up until instantiating the proxy for sending the request to the web service and calling it.

This is the ASP.NET code I can't follow:



How do I send out the request to get back the response URL in Java?






My Java code so far:
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brett Daburn:
This is the ASP.NET code I can't follow:


In AXIS, it is service locator object. Should be something like (providing that your port name is "SingleSignOnService"
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brett Daburn:
I got axis2 and created the code form the WSDL2Java from the web service's WSDL.



Axis2 WSDL2Java supports different styles of data binding which affects the style of objects that it generates. It defaults to ADB (Axis Data Binding).

If you have a look at the Axis 2 sample clients that are included in the distribution you will notice that ADB clients follow this pattern


ADB can get a bit confusing as complex types are often mapped to one class to represent the "type" and another class to represent the "element" (which contains the "type"). Example:


In this case ADB will create a SOAPStruct class with the properties and a MyElement class which contains a SOAPStruct instance. This could potentially clash with your mental model because it wouldn't unreasonable to expect the MyElement class to have the varString, varInt, and varFloat properties, just as the myElement element has the varString, varInt, and varFloat subelements - instead you have to set the properties on a SOAPStruct instance and then place the SOAPStruct instance in the MyElement instance.
This is referred to as the "Expanded" generation mode (which is the default).
[ November 25, 2008: Message edited by: Peer Reynders ]
 
Brett Daburn
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really appreciate the help. I believe that I have it set up correctly and am sending the request correctly. However, I am getting a timeout. Is there anything special you need to do to send to https?


Start:
- Deploying module: metadataExchange - file:/C:/Documents and Settings/c02378/Desktop/axis2-1.4.1/lib/mex-1.4.1.jar
- I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
- Retrying request
- I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
- Retrying request
- I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
- Retrying request
- Unable to sendViaPost to url[https://services.pj1.staging.printable.com/TRANS/0.9/SSO.asmx]
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:507)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:546)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:130)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
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 com.printable.services._1_0.sso.SingleSignOnStub.Authenticate(SingleSignOnStub.java:463)
at com.printable.services._1_0.sso.Test.main(Test.java:47)
org.apache.axis2.AxisFault: Connection timed out: connect
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 com.printable.services._1_0.sso.SingleSignOnStub.Authenticate(SingleSignOnStub.java:463)
at com.printable.services._1_0.sso.Test.main(Test.java:47)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:507)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:546)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:130)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
... 9 more
Done.





Here is my code:
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brett Daburn:
Is there anything special you need to do to send to https?




According to this document (Accessing Web Service via SSL) you have to first import the server certificate into a client truststore


and then set some client properties
 
Brett Daburn
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info Peer. Does it look like this is the reason for the timeout? I mean, do you get a timeout exception when you don't have the certificate in your TrustStore? I changed it to not use https and am still getting the timeout when you can place the URL in the browser without the https and still get a response.
 
Brett Daburn
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried making a simple get request using the following code sample and got the same timeout exception. I will need to figure out what is wrong with my environment not allowing requests. Then I will look into the certificate issue. Thank you for your help!
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brett Daburn:
I just tried making a simple get request using the following code sample and got the same timeout exception.



A SOAP endpoint doesn't have to respond to GET requests. SOAP requests are POSTed to the SOAP endpoint URI.
A well behaved SOAP endpoint would return 405 "Method Not Allowed" - however some SOAP stacks have a bit of tunnel vision when it comes to following proper HTTP etiquette.

Finally http is typically served on port 80 while https (SSL/TLS) is served on port 443. So it is entirely possible that nobody is listening on port 80 even when port 443 works.

Simply point your browser to the URL that is composed of the endpoint address and a "?wsdl" suffix

If the WSDL comes up it's likely that something is listening. If it doesn't come up the WSDL is suppressed or the server is down.
[ November 28, 2008: Message edited by: Peer Reynders ]
 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic