【发布时间】:2014-12-30 10:35:15
【问题描述】:
我有一个用 java 编写的简单的基于 SOAP 的 RPC 风格的 Web 服务。它有简单的字符串方法,从客户端获取字符串值并显示。客户端也是用 java 编写的。但是我如何编写一个 python 客户端来做同样的事情?谢谢。
下面给出了使用的代码。
服务端点
import javax.jws.WebService;
//Service Implementation
@WebService(endpointInterface = "com.test.webservice.HelloWorld")
public class HelloWorldImpl implements HelloWorld{
@Override
public String getHelloWorldAsString(String name) {
return "Hello World JAX-WS " + name;
}
}
Java Web 服务客户端
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import com.test.webservice.HelloWorld;
public class HelloWorldClient{
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:9999/ws/hello?wsdl");
//1st argument service URI, refer to wsdl document above
//2nd argument is service name, refer to wsdl document above
QName qname = new QName("http://webservice.test.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
System.out.println(hello.getHelloWorldAsString("name"));
}
}
}
【问题讨论】:
-
到目前为止你做了什么?
-
我试过这个教程codeproject.com/Articles/238778/…,但它给了我这个错误:文件“build\bdist.win32\egg\SOAPpy\WSDL.py”,第 114 行,在 getattr AttributeError: fetchData
标签: java python web-services soap