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 Invoking HTTPS webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Invoking HTTPS webservice" Watch "Invoking HTTPS webservice" New topic
Author

Invoking HTTPS webservice

Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


Is it possible to invoke a HTTPS web service methods from the application which i have it in my local?

If so, can you guide me giving a sample code?


Thanks,
Rajesh.B
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Web services are most often implemented as web apps running in a servlet container (if we're talking about a Java server). As long as the servlet container is set up for HTTPS, you should be able to use it for the web service.

On the client side you'd simply use "https" in the URL instead of "http".
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


The web service methods are hosted in HTTPS only. So, you mean to say, it is simple as like invoking HTTP methods?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Possibly. Have you tried it?
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Nope. Yet to work it out. Can you please help me how to start with?

Since i am very new to this.

Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


Could you please help me to create a client side application to invoke the HTTPS web service method?

The issue is, the "endpoint" is password protected. I navigated to the endpoint URL using the required credential and i can navigate.

Now i need to invoke through code. Could someone please help me?



Thanks,
Rajesh.B
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55


Please someone help me to finish it off. It's very urgent.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Generally, SOAP stacks (assuming that's what you're using, you haven't said anything about it) have tools that let you create client-side code from the WSDL. Might be named something like wsgen or wsdl2java.

Or are you using REST? In that you can just use a library like HttpClient (or even the HttpURLConnection class).
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


I can invoke the method but am getting the below error. Could you please let me know the reason?


[2/7/12 15:34:45:648 IST] 00000080 SystemErr R javax.xml.ws.WebServiceException: java.net.ConnectException: Connection timed out: no further information
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:559)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:118)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:82)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:319)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:159)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at $Proxy80.activateSIMPPU(Unknown Source)
[2/7/12 15:34:45:648 IST] 00000080 SystemErr R at Test.doGet(Test.java:57)


I believe, i need to pass the username and password of the WSDL file. But i don't know how to pass the credentials.
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


Can someone help me to fix the above issue?
Nischit Shetty
Greenhorn

Joined: Feb 21, 2007
Posts: 25
Hi Rajesh - Please invoke the webservice using SOAP UI or Firefox SOA plugin. these tools will act like a client and test whether the inteneded webservice is working. From the looks of the stack trace, it looked like you have no permission to invoke the service.
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi...

I have tried using SoapUI but am getting connection timedout error.

Could you please tell me why I couldn't invoke... Is there any specific reason?
Nischit Shetty
Greenhorn

Joined: Feb 21, 2007
Posts: 25
Rajesh - you have to employ trial and error technique to resolve your issue.

If you have the webservice URL, call it on your browser. Do you see any response? Does it say the webservice is up and running?
If not, I am guessing the below possible scenarios

1) Verify if the webservice is running at the specified port?
2) Verify if the webservice has to undergo form based authentication, basic authentication, etc
3) Check if the firewalls are not causing any issue (In your case i believe this is not a problem, but still check it out)
4) Are you the only one consuming this service? Any other app is using it? If so find out what they are doing?
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


I can invoke the webservice through the browser.

1) Verify if the webservice is running at the specified port?


Yeah It is running.

2) Verify if the webservice has to undergo form based authentication, basic authentication, etc


It needs basic authentication.

3) Check if the firewalls are not causing any issue (In your case i believe this is not a problem, but still check it out)


It might be the issue i believe. Do you have any idea of how to check this?

4) Are you the only one consuming this service? Any other app is using it? If so find out what they are doing?


I am sure about this.




David Nicholls
Greenhorn

Joined: Oct 10, 2011
Posts: 6

Hi Rajesh,

I assume that you want to call a SOAP webservice using apache axis2. Here is a code snippet that should do the work.


Good luck!
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Thanks a lot.


OMElement payload = <Create your payload>;



Could you tell me what i have do in <Create your payload>?

And which jar file is required for OMElement?
David Nicholls
Greenhorn

Joined: Oct 10, 2011
Posts: 6

I browsed the stack trace that you have posted earlier. Because of that I thought that you were already using apache axis2 to call the web service.

http://axis.apache.org/axis2/java/core/

Axis2 implements many of the WS-* specs. Find out for yourself if axis2 is right for you.
Axis2 uses the StAX API for XML processing. OMElement is the StAX equivalent for a DOM Element.
The payload is the XML portion that you put into the SOAP body of the SOAP message. It contains the method to call as well as the parameters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invoking HTTPS webservice