Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help Neeed to write a Client Application from WSDL

 
Dinesh Sundrani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Dinesh Sundrani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 108
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 78
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic