java - SOAP Webserice using Intellij-generated code, client certificate, and session cookies. Works stand-alone. Won't work in glassfish 3.1.2.2 -


i'm trying call 3rd party soap web service not control. service on https , requires both client-side certificate, user name , password, , session cookie passed during 1 of many redirects done on service side.

after pain, got working in stand-alone java application (using java 1.6) using below code:

(note: tableout, tablein, dmservice , datamanagementserviceporttype classes generated intellij wsdl)

public tableout callwebservice(tablein tin)throws exception{     system.setproperty("javax.net.ssl.keystore", getkeystorelocationfile().getabsolutepath());     system.setproperty("javax.net.ssl.keystorepassword", getkeystorepassword());     system.setproperty("javax.net.ssl.truststore", gettruststorelocationfile().getabsolutepath());     system.setproperty("javax.net.ssl.truststorepassword", gettruststorepassword());      authenticator.setdefault(new authenticator() {         public passwordauthentication getpasswordauthentication() {             return new passwordauthentication(getserviceuserid(), getservicepassword().tochararray());         }     });      cookiemanager manager = new cookiemanager(null, cookiepolicy.accept_all);     cookiehandler.setdefault(manager);      dmservice dmservice = new dmservice(new url(getendpointurl()), new qname("http://archserver.wsdl.dataflux.com", "dmservice"));     datamanagementserviceporttype port = dmservice.getport(dmservice.getservicename(), datamanagementserviceporttype.class);      map<string, object> reqcontext = ((bindingprovider)port).getrequestcontext();      reqcontext.put(bindingprovider.endpoint_address_property, getendpointurl());     reqcontext.put(bindingprovider.session_maintain_property, true);      tableout tout = port.datasvcuidwshcpddfin(tin); } 

the call returns desired results running in main method. however, true usage of web service call in context of larger, existing web application. problem i'm having seems i'm not getting cookies cookiemanager when running on application server. in app server not setting system properties glassfish has own keystore , cacerts, have had client , server certificates added, respectively. i'm learning stuff go i'm pretty new cookie handling, ssl certs , cookie handling in general.

i've written small jsp test including code above make sure larger application wasn't doing thwart cookie retrieval , then, no cookies in cookiemanager. i'm using glassfish 3.1.2.2 , java 1.6.

i'm out of ideas, suggestions welcome.

turns out either glassfish not using right keystore, or ignoring client key in keystore ended being certificate issue, not cookie issue (i wasn't getting cookie because wasn't passing cert). ended loading working keystore file url connection/ssl context , using way , works now.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -