gpt4 book ai didi

java - JAXWS — 如何更改端点地址

转载 作者:IT老高 更新时间:2023-10-28 20:33:08 24 4
gpt4 key购买 nike

如何动态更改我的 JAXWS 客户端正在使用的地址?此客户端由 wsimport 生成。

最佳答案

您可以使用 BindingProvider 接口(interface)来实现。

JAX-WS custom endpoint

/**
* The following snippets shows how to set a custom endpoint for a JAX-WS generated WebClient on runtime
*/

// Get the service and the port
SampleService service = new SampleService();
Sample port = service.getESamplePort();

// Use the BindingProvider's context to set the endpoint
BindingProvider bp = (BindingProvider)port;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://www.aviramsegal.com/ws/sample");

/* Optional credentials */
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "user");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
port.callSampleMethod();

关于java - JAXWS — 如何更改端点地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5158537/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com