How to setup HTTP Basic Authentication for SOAP Cl

2019-06-04 04:12发布

问题:

We are trying to deploy an EAR on WebSphere Liberty. Our application contains an EJB-module, which contains and EJB that makes a call to another SOAP server. The WSDL of the service defines a wsp:Policy with ExactlyOne of http:BasicAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http"/

After deployment when we send a request to our application, which would trigger that SOAP-call we get an error: None of the policy alternatives can be satisfied.

I found some java-code on how to solve this

HTTPConduit http = (HTTPConduit) client.getConduit(); 
http.getAuthorization().setUserName("user");
http.getAuthorization().setPassword("pass");

But I do not want to do this in the Java-code but I want to make it part of the server config.

I found several helpful links, but still could not get it working. Does anybody have any suggestions on how I can set this up?

https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/twlp_wssec_migrating.html

https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/twlp_sec_ws_clientcert.html

回答1:

You could use the JNDI feature to express the userid and password in server.xml, then have your java code pull it out of JNDI.

https://www.ibm.com/support/knowledgecenter/en/SSD28V_8.5.5/com.ibm.websphere.wlp.core.doc/ae/twlp_dep_jndi.html