下面给出了使用过的代码。
服务端点
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"));
}
}
}
答案 0 :(得分:0)
得到答案:
import suds
class Client:
def __init__(self):
self.client = suds.client.Client("http://localhost:9999/ws/hello?wsdl")
def getHelloWorldAsString(self):
return self.client.service.getHelloWorldAsString("name")
if(__name__ == "__main__"):
client = Client()
result = client.getHelloWorldAsString()
print result
来源: - http://www.codeproject.com/Articles/238778/Web-Services-in-Ruby-Python-and-Java