File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes jsp as web service client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Web Services
Bookmark "jsp as web service client" Watch "jsp as web service client" New topic

jsp as web service client

Hendra Kurniawan
Ranch Hand

Joined: Jan 31, 2011
Posts: 239
I have created and registered a web service. Now I wish to make a simple web app to access the web service. I used axis2 for the web service server. the client is provided with the data to be processed by the web service in the form of xml format file (data.xml). My jsp form has a textbox (to provide the location of the data.xml) and an "invoke" button that will access call the web service. I assume the jsp will first send the request to servlet and then the servlet will be the one responsible to call the web service.
lets say the web service is hosted in PC1, the web apps server that will access the web service is in PC2. I have the data.xml in PC3, so I will open the internet browser in PC3, access the jsp from PC2 which will then "invoke" the web service.
1. What's the syntax to call web service from servlet? I wonder if the axis2 is usable in the client side.
2. how do I construct the SOAP request (I assume the SOAP request is constructed in the servlet)? hopefully I don't need to construct the SOAP request string by string.
3. regarding data.xml, I assume jsp will upload the file to servlet, so the servlet will receive a file as parameter. Is this the correct way?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12888
0: You do NOT write the web service client in JSP, you write the client as a support class that can be tested outside the servlet/jsp environment.

1. Syntax is the same no matter where the client lives of course - nothing migic here. Note that if you want the request thread to carry out the SOAP client call to the service you better provide for all the possible things that can go wrong. See - 0 about testing outside the servlet environment first.

2. You can have traditional SOAP client tools build a SOAP request, but it will be MUCH simpler to have a stored template into which you insert current variable values (I guarantee it).

Hendra Kurniawan
Ranch Hand

Joined: Jan 31, 2011
Posts: 239
Hendra Kurniawan
Ranch Hand

Joined: Jan 31, 2011
Posts: 239
never mind. solved it. thanks
Satyaprakash Joshii
Ranch Hand

Joined: Jun 18, 2012
Posts: 140
Hendra..why dont you share with everyone how you solved it?
I agree. Here's the link:
subject: jsp as web service client