开发者

How to invoke a web service from a stand alone Java client?

I have an echo web service running on lets say http://localhost:8080/axis2开发者_开发百科/services/Service1. This service just echos back a string that is sent to it through the function echo(). Using the wsdl of the above mentioned service (Service.wsdl), I have generated (in eclipse) the ServiceStub.java and the ServiceCallbackHandler.java. With these two files, how can I write a client which will invoke echo(String some_word) and receive the response back? Thanks.


If you simply want to test/exercise your web service, I recommend SOAPUI - http://www.soapui.org/

Point it at your WSDL and it will allow you to call your Web Service methods.


Check Eclipse WTP Tutorials - Creating Bottom Up Web Service via Apache Axis2, starting from step 27.


Something like this:
(see also: Axis2 Web Service (Tomcat v6)

package com.gg.ws;

import java.rmi.RemoteException;

import com.gg.ws.ServiceStub.Echo;
import com.gg.ws.ServiceStub.EchoResponse;


public class WebServiceTest {

    public void callEcho() throws RemoteException {

        ServiceStub stub = new ServiceStub();

        Echo request = new Echo();
        request.setValue("Whatever");
        EchoResponse response = stub.echo(request);
        System.out.println(" echo call   response: " + response.get_return());
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜