我运行了一个echo web服务,比如http://localhost:8080/axis2/services/Service1
。此服务只回显一个通过函数echo()
发送给它的字符串。使用上述服务(Service.wsdl)的wsdl,我已经生成了(在eclipse中)ServiceStub.java和ServiceCallbackHandler.java。使用这两个文件,如何编写将调用echo(String some_word)
并接收响应的客户端?感谢。
答案 0 :(得分:2)
如果您只是想测试/锻炼您的网络服务,我推荐使用SOAPUI - http://www.soapui.org/
将它指向您的WSDL,它将允许您调用Web服务方法。
答案 1 :(得分:0)
答案 2 :(得分:0)
这样的事情:
(另见: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());
}
}