问题描述
我有一个用于Web服务的WSDL文件.我正在使用JAX-WS/wsimport生成Web服务的客户端接口.我不知道网络服务将在其上运行的主机,我几乎可以保证它不会是 http ://localhost:8080 .如何在运行时指定主机网址,例如从命令行参数?
I have a WSDL file for a web service. I'm using JAX-WS/wsimport to generate a client interface to the web service. I don't know ahead of time the host that the web service will be running on, and I can almost guarantee it won't be http://localhost:8080. How to I specify the host URL at runtime, e.g. from a command-line argument?
生成的构造函数MyService(URL wsdlLocation, QName serviceName)
似乎不是我想要的,但也许是吗?也许是Service.getPort(...)
的变体之一?
The generated constructor MyService(URL wsdlLocation, QName serviceName)
doesn't seem like what I want, but maybe it is? Perhaps one of the variants of Service.getPort(...)
?
谢谢!
推荐答案
构造函数应该可以很好地满足您的需求,当您创建MyService时,将您想要的WSDL的URL传递给它,即 http://someurl:someport/service?wsdl .
The constructor should work fine for your needs, when you create MyService, pass it the url of the WSDL you want i.e. http://someurl:someport/service?wsdl.
这篇关于从JAX-WS生成的代码访问Web服务时,如何指定主机和端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!