Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

XFIRE

 
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using XFIRE, and i want to invoke my web service from a web browser. Can anybody tell me how ?

I am being able to view the WDSL file as the following: http://localhost:8080/WS/services/WebServiceTest?wsdl

But i want to invoke a method named example in this service, so what shall i do ?

Thanks,
 
Ranch Hand
Posts: 2198
1
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

run this code to test any XFire web serivce. Test is my service implementation class.

public class Test1 {

private static String serviceUrl = "http://localhost:8084/test-web-app1/services/Test";

public static void main(String[] args) throws Exception {
log("Client.main : Start...");
if (args.length > 0) {
serviceUrl = args[0];
}
Test1 client = new Test1();
log("Response from WEB SERVICE: " + client.callWebService("adsf"));
log("Client.main : End.");
}

public String callWebService(String name) throws Exception {

log("Client.main : Start...");
//Create a metadata of the service
Service serviceModel = new ObjectServiceFactory().create(Test.class);
log("callSoapServiceLocal(): got service model.");

//Create a proxy for the deployed service
XFire xfire = XFireFactory.newInstance().getXFire();
XFireProxyFactory factory = new XFireProxyFactory(xfire);

Test client = null;
try {
client = (Test) factory.create(serviceModel, serviceUrl);
} catch (Throwable e) {
e.printStackTrace();
log("WsClient.callWebService(): EXCEPTION: " + e.toString());
}

//Invoke the service
String serviceResponse = "";
try {
serviceResponse = client.test();
} catch (Exception e) {
log("Client.callWebService(): EXCEPTION: " + e.toString());
serviceResponse = e.toString();
}
log("Client.main : End. status = " + serviceResponse);

//Return the response
return serviceResponse;
}

public static void log(Object msg) {
System.out.println(msg.toString());
}
}
 
Beware the other head of science - it bites! Nibble on this message:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic