从JAX-WS生成的代码访问Web服务时,如何指定主机和端口? [英] How do I specify host and port when accessing a web service from JAX-WS-generated code?

查看:62
本文介绍了从JAX-WS生成的代码访问Web服务时,如何指定主机和端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于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传递给它,即

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服务时,如何指定主机和端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆