Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Java Client for Webservices

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read about wsdl to java or soapUI
 
Look! It's Leonardo da Vinci! And he brought a tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic