aspose file tools*
The moose likes Web Services and the fly likes Java Client for Webservices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Java Client for Webservices" Watch "Java Client for Webservices" New topic
Author

Java Client for Webservices

rudresh kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 83
Hi All,

I have wsdl and i have created a java skeleton/stubs/proxy/servicelocator using eclipse/Axis, would like to know how the client code would be, which will invoke the services

i have searched thro net but found the following
Service service = new Service();
Call call = (Call) service.createCall();
then invoke..

but the above code does not use the stubs/skeletons at all which was generated in eclipse

Can i know how to invoke the webservice using the skeleton/stubs/proxy/servicelocator

Thanks in advance
hardikkumar patel
Greenhorn

Joined: Jul 06, 2009
Posts: 3
If you have created web Service using Axis2/Eclipse then you can use Web Services Explorer of Eclipse to test your web service.
Sachin Paradkar
Greenhorn

Joined: Jul 28, 2004
Posts: 6
rudresh kumar wrote:Hi All,

I have wsdl and i have created a java skeleton/stubs/proxy/servicelocator using eclipse/Axis, would like to know how the client code would be, which will invoke the services

i have searched thro net but found the following
Service service = new Service();
Call call = (Call) service.createCall();
then invoke..

but the above code does not use the stubs/skeletons at all which was generated in eclipse

Can i know how to invoke the webservice using the skeleton/stubs/proxy/servicelocator

Thanks in advance


Hi Rudresh,

You can try using the below code for creating java clients .

package samples.quickstart.clients;

import samples.quickstart.service.xmlbeans.StockQuoteServiceStub;
import samples.quickstart.service.xmlbeans.xsd.GetPriceDocument;
import samples.quickstart.service.xmlbeans.xsd.GetPriceResponseDocument;
import samples.quickstart.service.xmlbeans.xsd.UpdateDocument;

public class XMLBEANSClient{

public static void main(java.lang.String args[]){
try{
StockQuoteServiceStub stub =
new StockQuoteServiceStub
("http://localhost:8080/axis2/services/StockQuoteService");

getPrice(stub);
update(stub);
getPrice(stub);

} catch(Exception e){
e.printStackTrace();
System.err.println("\n\n\n");
}
}

/* fire and forget */
public static void update(StockQuoteServiceStub stub){
try{
UpdateDocument reqDoc = UpdateDocument.Factory.newInstance();
UpdateDocument.Update req = reqDoc.addNewUpdate();
req.setSymbol ("BCD");
req.setPrice (42.32);

stub.update(reqDoc);
System.err.println("price updated");
} catch(Exception e){
e.printStackTrace();
System.err.println("\n\n\n");
}
}

/* two way call/receive */
public static void getPrice(StockQuoteServiceStub stub){
try{
GetPriceDocument reqDoc = GetPriceDocument.Factory.newInstance();
GetPriceDocument.GetPrice req = reqDoc.addNewGetPrice();
req.setSymbol("BCD");

GetPriceResponseDocument res =
stub.getPrice(reqDoc);

System.err.println(res.getGetPriceResponse().getReturn());
} catch(Exception e){
e.printStackTrace();
System.err.println("\n\n\n");
}
}
}


Find the link here ---->> http://ws.apache.org/axis2/1_4/quickstartguide.html#clientaxiom

Thanks,
Sachin Paradkar

SachinParadkar
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Read about wsdl to java or soapUI


===Vyas Sanzgiri===
My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Client for Webservices