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

client side calling web service

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
If someone writes web service and makes it available via publishing his WSDL. If I want to write a client to call that web service, do I need to have some jar file he created from WSDL2Java ? I guess I need such thing otherwise how does client invokes through stub ? So I guess I need to have those jar file included in my local Classpath.

But on the other hand, is it bit weird to me -- If you write a web service and wants others to remotely uses it, how can you give them your jar ? This does not sound reasonable.

So what's the actual scenario in real world ?
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
If I understand this phrase "how does client invokes through stub ?" correctly you mean how the client side contacts the server side?

In any case when I have created webservice client side classes with Apache Axis for example the created classes use the Apache Axis to make the actual calls also. And I would guess that is the case with any other third party library. If you are talking about some standard J2EE way of creating the client side classes I would presume that the created classes use the standard J2EE classes then also. The WSDL only tells where to make contact and with what kind of objects (classes for those objects are naturally also created in the process) and it is the calling side that decides what jar library to use and where to get it.

If on the other hand there are very complicated structures needed (like for example thousands of different kinds of objects that live in relationship with each other) then I would guess that the party that provided the WSDL can give you a jar packet containing classes for those. If I remember correctly SalesForce does this. Or at least did. Could be wrong. They update their concept so often that it is hard to keep track.
Jim Akmer
Ranch Hand

Joined: Jul 06, 2010
Posts: 104
@Ben oliver: You do not have to deliver any jar file to the client side. The person implementing the web service client, will use the wsdl you have exposed for your web service and will use a tool to generate all the artifacts necessary to communicate with your web service.
As long as your wsdl is well defined and the client can find your wsdl -the wsdl you either give it to the client side (not a jar) or you publish it via a registry, you do not have to provide anything else. Hope this clears your question.
ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
Jim Akmer wrote:@Ben oliver: You do not have to deliver any jar file to the client side. The person implementing the web service client, will use the wsdl you have exposed for your web service and will use a tool to generate all the artifacts necessary to communicate with your web service.
As long as your wsdl is well defined and the client can find your wsdl -the wsdl you either give it to the client side (not a jar) or you publish it via a registry, you do not have to provide anything else. Hope this clears your question.


can you be more specific on "will use a tool to generate all the artifacts necessary to communicate with your web service". What tool ?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
ben oliver wrote:
can you be more specific on "will use a tool to generate all the artifacts necessary to communicate with your web service". What tool ?

For instance wsimport available in the Java SE 6 distribution.
Best wishes!
Anthony Andras
Ranch Hand

Joined: Nov 09, 2008
Posts: 31
The individual who composes the client side code generally is the one who runs WSDL2Java. The person who publishes the WSDL typically has no concern about how the client generates the appropriate code to call the service. This is the beauty of web services. There is no coupling between client and server implementations.

If client code generation is of interest to you, I recommend taking a read through: http://ws.apache.org/axis2/1_1_1/userguide-creatingclients.html

This page helped me significantly when being faced with the task of writing client side code to communicate to web services (using Axis2).
Jim Akmer
Ranch Hand

Joined: Jul 06, 2010
Posts: 104
@Ben: WSDL are documents that are (usually) not mean to be handled by programmers. There are various tools that parse the WSDL file and automatically generate all the artifacts required, to call the web service. By artifacts I mean all the classes necessary to call the web service and marshall/demarshall the request/responses to/from web service. The web service client code just makes a "regular" method call, that under the covers sends the request and receives the response over the network.
There are many tools, and frameworks. wsimport mentioned by Ivan is shipped with jdk, wsd2java from axis or cxf etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client side calling web service