I want to enable client side validation of my SOAP messages before sending them to the endpoint.
How can I enable it in my client application running in WebLogic 10.3.6 / Metro provider, preferably using the JAX-WS API?
Metro version is JAX-WS RI 2.1.6 in JDK 6.
Here is a sample code of my JAX-WS client:
@WebService
public class Client {
@WebServiceRef(wsdlLocation = "RemoteService.wsdl")
private RemoteService_Service service;
public void call() throws Exception {
RemoteService port = service.getRemoteServicePort();
// configures authentication
auth(port);
// builds request
Request request = new Request();
request.setValue(null); // this field is mandatory in server
// client must validate and raise an exception
port.someOperation(request);
}
protected void auth(RemoteService port) {
Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();
requestContext.put(BindingProvider.USERNAME_PROPERTY, "changeit");
requestContext.put(BindingProvider.PASSWORD_PROPERTY, "changeit");
}
}
Metro documentation Client Side Schema Validation describes how to do it: