jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Web service using HttpURLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Web service using HttpURLConnection" Watch "Web service using HttpURLConnection" New topic

Web service using HttpURLConnection

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

Dear Friends,

I am connecting to a java web service from a java client program. Both developed by me for learning purpose. I created the WSDL from the java web service class and i generated the ServiceLocator and stub classes using Eclipse lomboz tool. Now i am trying to connect to the web service using HttpUrlConnection. I developed the following code for that:

My problem is, if i used the generated stub and service locator classes generated from the WSDL i can directly call the web service method from the java client. But if i use this HttpURLConnection API for web service access how can i call the web service method i need?

Please provide your help and suggestions for this problem.

Thanks & Regards,

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
You'd need to send and receive SOAP messages. While SOAP is not a complicated protocol, assembling a request correctly (and later parsing the response) isn't trivial, either. I wouldn't advise to code that yourself.

If you want something that works on a lower level than using the generated code, you might look into writing a SAAJ client.
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

Dear Ulf,

Thank you very much for your help.

I agree. Here's the link: http://aspose.com/file-tools
subject: Web service using HttpURLConnection
It's not a secret anymore!