Search code examples
javaeclipseweb-serviceswsdlaxis

How to utilize web service client generated from WSDL?


I'm trying to write a simple web service client to interact with my simple web service which only returns a user id that's passed in. So I created a web service client in eclipse and generated a few files for me; wsCall, wsCallBindingStub, wsCallProxy, wsCallService, wsCallServiceLocator. The stub is the conly class I found that has my web service methods in it, because my ws is simple at this stage?

So I want to invoke the call, what do I need to make the call?

I've seen all the examples online have the try-catch for a remote exception or Axis fault, then the classes are instantiated (including a response class, to deserialize?) and make the ws call via the stub class. Is that all I need to call for my case?

wsCallBindingStub stub = new wsCallBindingStub();
String retString = stub.sayHi(1); // 1: my user id
return retString;

Thank you!


Solution

  • Ahh I figured it out, I was getting an error because my wsdl uses the hostname and I needed to specify the ip.. as for the code needed it was pretty much identicle;

    wsCall ws = new wsCallServiceLocator().getWsCallPort();
    result = ws.sayHi(x);