I am calling the HTTPS SOAP web service through Java code. I have already imported a self-signed certificate in jre cacerts keystore. Now I get:
com.sun.xml.internal.ws.com.client.ClientTransportException: HTTP transport error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
The host name of the service URL does not match the CN name specified in the certificate. I read about a workaround for defining a custom host verifier here . But I can not do where I have to use a workaround in my code.
public SOAPMessage invokeWS(WSBean bean) throws Exception { SOAPMessage response=null; try{ String targetNameSpace = bean.getTargetNameSpace(); String endpointUrl = bean.getEndpointUrl(); QName serviceName = new QName(targetNameSpace, bean.getServiceName()); QName portName = new QName(targetNameSpace, bean.getPortName()); String SOAPAction = bean.getSOAPAction(); HashMap<String, String> map = bean.getParameters(); Service service = Service.create(serviceName); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl); Dispatch dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
Please ignore the WSBean parameter, as namespaces and other wsdl attributes come from this bean. And if this exception can be resolved with some workarounds, pls really offer one.
shashankaholic Apr 21 '12 at 10:24 2012-04-21 10:24
source share