如何更改 webservice url 端点? [英] How to change webservice url endpoint?

查看:32
本文介绍了如何更改 webservice url 端点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 JBoss utils(JAX-WS 兼容)生成了一个 web 服务客户端使用 Eclipse来自 wsdl 的 Web 服务客户端".

I generated a web-service client using JBoss utils (JAX-WS compatible) using Eclipse 'web service client from a wsdl'.

因此,我提供的唯一内容是 Web 服务 WSDL 的网址.

So, the only thing I provided was a url to a web-service WSDL.

现在,Web 服务提供商告诉我更改 Web 服务的客户端端点应用程序访问 URL".

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?

推荐答案

IMO,提供者告诉您更改服务端点(即到达 Web 服务的位置),而不是客户端端点(我不明白是什么这可能是).要更改服务端点,您基本上有两种选择.

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.

第一个选项是更改 BindingProviderBindingProvider.ENDPOINT_ADDRESS_PROPERTY 属性值(每个代理都实现了 javax.xml.ws.BindingProvider界面):

The first option is to change the BindingProvider.ENDPOINT_ADDRESS_PROPERTY property value of the BindingProvider (every proxy implements javax.xml.ws.BindingProvider interface):

...
EchoService service = new EchoService();
Echo port = service.getEchoPort();

/* Set NEW Endpoint Location */
String endpointURL = "http://NEW_ENDPOINT_URL";
BindingProvider bp = (BindingProvider)port;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);

System.out.println("Server said: " + echo.echo(args[0]));
...

缺点是这仅在原始 WSDL 仍可访问时才有效.不推荐.

The drawback is that this only works when the original WSDL is still accessible. Not recommended.

第二个选项是从 WSDL 获取端点 URL.

The second option is to get the endpoint URL from the WSDL.

...
URL newEndpoint = new URL("NEW_ENDPOINT_URL");
QName qname = new QName("http://ws.mycompany.tld","EchoService"); 

EchoService service = new EchoService(newEndpoint, qname);
Echo port = service.getEchoPort();

System.out.println("Server said: " + echo.echo(args[0]));
...

这篇关于如何更改 webservice url 端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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