I want to configure a managed JAX-WS client (injected with @WebServiceRef
) from outside the application, preferably using WebLogic Admin Console.
For example, set the username and password that will be sent in the HTTP request to authenticate on the server when performing the Web Service call.
To be clear, doing it manually requires me to implement it, while using a feature provided by the container requires only configuration.
I was able to do it using SAP NetWeaver, is it possible to do it with WebLogic?
@Stateless
public class HolidayClientImpl {
// I want this dependency to be already configured, instead of doing it myself.
@WebServiceRef
private MyRemoteService myRemoteService;
}
After searching a lot I didn't find this functionality to be available in WebLogic. It doesn't exist, at least at version 10.3.6 and 12 as well.
That means you have to implement the client configuration, something like this:
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");