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

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

问题描述

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

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

所以,我唯一提供的是Web服务WSDL的URL。

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

现在,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.

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

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.

第二个选项是获取端点URL来自WSDL。

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天全站免登陆