如何更改 Web 服务 url 端点?
我使用 JBoss utils(JAX-WS 兼容)生成了一个 Web 服务客户端 使用 Eclipse“来自 wsdl 的 Web 服务客户端”。
因此,我唯一提供的就是 Web 服务 WSDL 的 URL。
现在,Web 服务提供商告诉我更改 Web 服务的“客户端端点应用程序访问的 URL”。
它是什么以及如何改变它?
I generated a web-service client using JBoss utils (JAX-WS compatible)
using Eclipse 'web service client from a wsdl'.
So, the only thing I provided was a url to a web-service WSDL.
Now, the web service provider tells me to change the "url of client endpoint application access" of the web-service.
What is it and how to change it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
IMO,提供商告诉您更改服务端点(即到达 Web 服务的位置),而不是客户端端点(我不明白这可能是什么)。要更改服务端点,您基本上有两种选择。
使用 Binding Provider 设置端点 URL
第一个选项是更改
BindingProvider.ENDPOINT_ADDRESS_PROPERTY
的BindingProvider
属性值(每个代理都实现javax.xml.ws .BindingProvider
接口):缺点是这仅在原始 WSDL 仍可访问时才有效。不推荐。
使用 WSDL 获取端点 URL
第二个选项是从 WSDL 获取端点 URL。
IMO, the provider is telling you to change the service endpoint (i.e. where to reach the web service), not the client endpoint (I don't understand what this could be). To change the service endpoint, you basically have two options.
Use the Binding Provider to set the endpoint URL
The first option is to change the
BindingProvider.ENDPOINT_ADDRESS_PROPERTY
property value of theBindingProvider
(every proxy implementsjavax.xml.ws.BindingProvider
interface):The drawback is that this only works when the original WSDL is still accessible. Not recommended.
Use the WSDL to get the endpoint URL
The second option is to get the endpoint URL from the WSDL.
在此添加一些说明,当您创建服务时,服务类使用默认的“wsdlLocation”,该类是在从 wsdl 构建该类时插入的。因此,如果您有一个名为 SomeService 的服务类,并且创建一个如下所示的实例:
如果您查看 SomeService 内部,您将看到构造函数如下所示:
因此,如果您希望它指向另一个 URL,只需使用构造函数它接受一个 URL 参数(还有 6 个构造函数用于设置 qname 和功能)。例如,如果您设置了一个正在侦听端口 9999 的本地 TCP/IP 监视器,并且您想要重定向到该 URL:,
那么这将在服务内调用此构造函数:
To add some clarification here, when you create your service, the service class uses the default 'wsdlLocation', which was inserted into it when the class was built from the wsdl. So if you have a service class called SomeService, and you create an instance like this:
If you look inside SomeService, you will see that the constructor looks like this:
So if you want it to point to another URL, you just use the constructor that takes a URL argument (there are 6 constructors for setting qname and features as well). For example, if you have set up a local TCP/IP monitor that is listening on port 9999, and you want to redirect to that URL:
and that will call this constructor inside the service:
我不会像 @Femi 那样更改现有的地址属性。您可以轻松地将新服务添加到定义部分。
这不需要将 WSDL 重新编译为 Java,并且更新并不比使用 BindingProvider 选项(顺便说一句,这对我不起作用)更困难。
I wouldn't go so far as @Femi to change the existing address property. You can add new services to the definitions section easily.
This doesn't require a recompile of the WSDL to Java and making updates isn't any more difficult than if you used the BindingProvider option (which didn't work for me btw).
要更改结束地址属性,请编辑您的 wsdl 文件
To change the end address property edit your wsdl file