我想从应用程序外部配置托管JAX-WS客户端(注入@WebServiceRef
) ,最好使用WebLogic管理控制台。
例如,设置在HTTP请求中发送的用户名和密码,以便在执行Web服务调用时在服务器上进行身份验证。
要清楚,手动执行操作需要我实现它,而使用容器提供的功能只需要配置。
我能够使用SAP NetWeaver做到这一点,是否可以使用WebLogic做到这一点?
@Stateless
public class HolidayClientImpl {
// I want this dependency to be already configured, instead of doing it myself.
@WebServiceRef
private MyRemoteService myRemoteService;
}
答案 0 :(得分:0)
经过大量搜索后,我发现WebLogic中没有此功能。它不存在,至少在版本10.3.6和12中也是如此。
这意味着您必须实现客户端配置,如下所示:
MyPort port = service.getHTTPPort();
Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();
// URL
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://www.remoteservice.com/service");
// Timeouts
requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, 5000);
requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, 30000);
// Authentication
requestContext.put(BindingProvider.USERNAME_PROPERTY, "user");
requestContext.put(BindingProvider.PASSWORD_PROPERTY, "password");