aspose file tools*
The moose likes Web Services and the fly likes Help Neeed to write a Client Application from WSDL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Help Neeed to write a Client Application from WSDL" Watch "Help Neeed to write a Client Application from WSDL" New topic
Author

Help Neeed to write a Client Application from WSDL

Dinesh Sundrani
Ranch Hand

Joined: Mar 21, 2006
Posts: 78
Hi Friends

I am new to Web Service Technology. I want to write a simple client application (without using any third part tool like axis or anything) that will make use of my Calculator.wsdl. I mean, the Client should be able to call mathod like add(2,5) and get a response as 7.

I have pasted the WSDL below

<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://www.dinesh.com/calc/Calculator">
<!--ADD-->
<message name="addRequest">
<part name="parm1" type="xsd:int" />
<part name="parm2" type="xsd:int" />
</message>
<message name="addResponse">
<part name="addReturn" type="xsd:int" />
</message>

<!--SUBTRACT-->
<message name="subtractRequest">
<part name="parm1" type="xsd:int" />
<part name="parm2" type="xsd:int" />
</message>
<message name="subtractResponse">
<part name="subtractReturn" type="xsd:int" />
</message>

<portType name="Calculator">
<operation name="add">
<input message="intf:addRequest" name="addRequest" />
<output message="intf:addResponse" name="addResponse" />
</operation>
<operation name="subtract">
<input message="intf:subtractRequest" name="subtractRequest" />
<output message="intf:subtractResponse" name="subtractResponse" />
</operation>
</portType>
</definitions>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41865
    
  63
will make use of my Calculator.wsdl

What do you mean by this? Do you just want to write a client that can access a WS that's described by the WSDL, or do you want to write a generic client that can access the WSDL, and then build and execute a WS call based on the contents of the WSDL? The latter would be quite an advanced project. For the former, it's probably easiest to write a SAAJ client, if you don't want to use tools that generate the code for you. But I'm curious: why don't you?


Ping & DNS - my free Android networking tools app
Dinesh Sundrani
Ranch Hand

Joined: Mar 21, 2006
Posts: 78
Hi

I want to write a client that can access my WS that's described by the WSDL,

Please let me know how can I achieve it?

Regards,
Dinesh S
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
If you insists on learning things the hard way - then do them the hard way:
  • Learn about SOAP
  • Learn about how WSDL describes what SOAP messages should look like
  • Interpret the WSDL and handcraft the SOAP request message
  • Write a program to send the SOAP request over a URL connection
  • Parse/XPath/Regex match the SOAP response to extract the results


  • Of course you could simply "cheat" and follow a simple tutorial like Creating Web Services with Apache Axis - then apply what you have learned to do the same to your WSDL/web service and use the provided tools like Axis tcpmon to see the generated SOAP messages - and then use those in your "really simple client".
    [ April 21, 2006: Message edited by: Peer Reynders ]
    Ben Ethridge
    Ranch Hand

    Joined: Jul 28, 2003
    Posts: 108
    Hi.

    Try Kent Tong's book:

    http://agileskills2.org/DWSAA/

    It has good examples of how to write clients (which may even be in the first 40 free pages above). It also does a very good job of explaining the basics, conceptually and syntactically.

    Ben
    Dinesh Sundrani
    Ranch Hand

    Joined: Mar 21, 2006
    Posts: 78
    Hi Friends

    I was able to write a simple Client Program (Java Application with main() method) that read the sample Input SOAP Request, Created a URL Connection to the Service URI of the WSDL, send the SOAP message to the WSDL using the newly created connection and then got and parsed the response.

    Now I want to move on to the next step..

    Say Suppose I have a WSDL file with me called Calculator.wsdl and I want to create a clientjar-calculator.jar from it using the weblogic ant task called "clientgen". So now I need to make use of this client jar to write my client application that could get the port information and invoke the service like add(1,2) or subtract(1,2) on the exposed web services as described by the WSDL.

    Could anyone help me on this one?

    Thanks a lot!!

    Regards,
    Dinesh Sundrani
    wise owen
    Ranch Hand

    Joined: Feb 02, 2006
    Posts: 2023
    Invoking a Web Service from a Stand-alone Client: Main Steps and Writing the Java Client Application Code to Invoke a Web Service.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Help Neeed to write a Client Application from WSDL