Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Client for Webservices

 
rudresh kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read about wsdl to java or soapUI
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic