Java code snippet similar to proxies.xml to setup a SSL for SOAP service

64 views
Skip to first unread message

neshant sharma

unread,
Mar 16, 2018, 2:07:20 AM3/16/18
to membrane-monitor

I have been spending quite some to figure out how to have the java code perform similar to this xml config file

The below config proxies the wsdl to https. I can access the wsdl file on https://localhost:2002/axis2/services/BLZService



<soapProxy port="2002" wsdl="http://www.thomas-bayer.com/axis2/services/BLZService?wsdl">
<ssl>
	<keystore location="membrane.jks" password="secret" keyPassword="secret" />
	<truststore location="membrane.jks" password="secret" />
</ssl>
</soapProxy>


when I try to do the same using below java code it does not work. I am unable to figure out what am I missing here. The below does not host the wsdl on https://localhost:2002/axis2/services/BLZServiceand it is only accessible on http://localhost:2002/axis2/services/BLZService despite admin console showing SSL for this.

It shows the links with https but they do not open. Basically I want my java code to work similar as the above proxies xml works and the wsdl should be published on https...




SOAPProxy sp = new SOAPProxy();
    sp.setWsdl("http://www.thomas-bayer.com/axis2/services/BLZService?wsdl");
    sp.setPort(2002);

    SSLParser sslParser = new SSLParser();
    KeyStore keyStore = new KeyStore();
    keyStore.setLocation("file:///Users/neshant/Downloads/membrane-service-proxy-4.5.1/conf/membrane.jks");
    keyStore.setKeyPassword("secret");
    keyStore.setPassword("secret");
    TrustStore trustStore = new TrustStore();
    trustStore.setPassword("secret");
    trustStore.setLocation("file:///Users/neshant/Downloads/membrane-service-proxy-4.5.1/conf/membrane.jks");
    sslParser.setTrustStore(trustStore);
    sslParser.setKeyStore(keyStore);

    sp.setSslInboundParser(sslParser);


    //Admin console
    AbstractServiceProxy abstractServiceProxy = new ServiceProxy();
    abstractServiceProxy.setKey(new ServiceProxyKey(9001));
    abstractServiceProxy.getInterceptors().add(new AdminConsoleInterceptor());

    HttpRouter router = new HttpRouter();
    router.add(sp);
    router.add(abstractServiceProxy);


    router.init();





As you can see in attachment image that despite setting the inbound parser in the java code the the url is not a https:// but the url in the links are https and they do NOT open.

When I click on https url in the link it shows "Establishing Secure Connection" which just times out.
Looks like the website is not being hosted on https:// at all



Please correct me if I am doing something wrong above.

37474373-6aa15cbc-282d-11e8-9125-2becc1424808.png
Reply all
Reply to author
Forward
0 new messages