我正在尝试为使用jaxws-maven-plugin生成的jax-ws-webservice-client设置请求(和连接)超时.在tomcat或jetty下运行我的应用程序时,超时工作正常,但是当在jboss下部署时它不会"占用".
private void setRequestAndConnectionTimeout(Object wsPort) {
String REQUEST_TIMEOUT = BindingProviderProperties.REQUEST_TIMEOUT; // "com.sun.xml.ws.request.timeout";
((BindingProvider) wsPort).getRequestContext().put(REQUEST_TIMEOUT, timeoutInMillisecs);
((BindingProvider) wsPort).getRequestContext().put(JAXWSProperties.CONNECT_TIMEOUT, timeoutInMillisecs);
}
Run Code Online (Sandbox Code Playgroud)
为JBoss执行此操作的正确方法是什么?
下面的wsdlLocation是受密码保护的,但是偏执使我为应用程序设置默认的Authenticator感到不舒服.如何在不使用默认身份验证器的情况下设置身份验证?
protected Orders getOrdersPort(String wsdlLocation, String namespaceURI) {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password".toCharArray());
}
});
OrdersService service = new OrdersService(createUrlThrowRuntimeException(wsdlLocation), new QName(namespaceURI,
"OrdersService"));
Orders ordersPort = service.getOrdersSoap12();
setConnectionTimeout(ordersPort);
return ordersPort;
}
Run Code Online (Sandbox Code Playgroud)