java 如何从java代码调用Web服务?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4171180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to call web service from java code?
提问by user506518
I want to call a web service "gatewaedi" from java code.
我想从 Java 代码中调用 Web 服务“gatewaedi”。
I am not getting how to call it, could someone please provide an example?
我不知道如何称呼它,有人可以提供一个例子吗?
回答by mariana soffer
This is how you call a webservice with JAX-RPC
这就是您使用 JAX-RPC 调用 Web 服务的方式
String wsdlURL = "http://localhost:6080/HelloWebService/services/Hello?wsdl"[1];
String namespace = "http://Hello.com"[2];
String serviceName = "GatewaediWebService";
QName serviceQN = new QName(namespace, serviceName);
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service service = serviceFactory.createService(serviceQN);
Should be replaced by the gatewaedi webservice call, which I can not find now.
Should be replaced by the gatewaedi webservice corresponding namespace, that too I can't find.
应该替换为gatewaedi webservice 调用,我现在找不到了。
应该换成gatewaedi webservice对应的namespace,那个我也找不到。
If you want send me more information about this webservice and I will write you the complete code.
如果您想向我发送有关此网络服务的更多信息,我会为您编写完整的代码。