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