You need to sign in to do that
Don't have an account?
![Nuevo9763 Nuevo9763](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
add ws security header in external request to SalesForce Api
I am trying to connect to SalesForce from Java and need to add <wsse:security> to my SOAP request. I can connect with security header added to Soap Header in SOAP UI but not able to do the same using java. I added requestHeader in ConnnecorConfig like below.
cfg.setRequestHeader("wsse:Security ", createSecurityHeader());
This does not work. My OAP request works with the wsse security header in SOAP UI. But not able to do that in Java.
Settin the seciurity header like above throws exception:
Exception in thread "main" java.lang.IllegalArgumentException: Illegal character(s) in message header field: wsse:Security
at sun.net.www.protocol.http.HttpURLConnection.checkMessageHeader(HttpURLConnection.java:522)
at sun.net.www.protocol.http.HttpURLConnection.isExternalMessageHeaderAllowed(HttpURLConnection.java:492)
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3057)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:316)
at com.sforce.ws.transport.JdkHttpTransport.createConnection(JdkHttpTransport.java:169)
at com.sforce.ws.transport.JdkHttpTransport.connectRaw(JdkHttpTransport.java:131)
at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:103)
at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:98)
at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:94)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:104)
at com.sforce.soap.partner.PartnerConnection.login(PartnerConnection.java:817)
at com.sforce.soap.partner.PartnerConnection.<init>(PartnerConnection.java:426)
.
Any help is appreciated.
Thanks
cfg.setRequestHeader("wsse:Security ", createSecurityHeader());
This does not work. My OAP request works with the wsse security header in SOAP UI. But not able to do that in Java.
Settin the seciurity header like above throws exception:
Exception in thread "main" java.lang.IllegalArgumentException: Illegal character(s) in message header field: wsse:Security
at sun.net.www.protocol.http.HttpURLConnection.checkMessageHeader(HttpURLConnection.java:522)
at sun.net.www.protocol.http.HttpURLConnection.isExternalMessageHeaderAllowed(HttpURLConnection.java:492)
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3057)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:316)
at com.sforce.ws.transport.JdkHttpTransport.createConnection(JdkHttpTransport.java:169)
at com.sforce.ws.transport.JdkHttpTransport.connectRaw(JdkHttpTransport.java:131)
at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:103)
at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:98)
at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:94)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:104)
at com.sforce.soap.partner.PartnerConnection.login(PartnerConnection.java:817)
at com.sforce.soap.partner.PartnerConnection.<init>(PartnerConnection.java:426)
.
Any help is appreciated.
Thanks
I see you also posted your query here.SF does not support WS-Security out of the box.
Questions related to Java are best suited on the Stackoverflow site for right visibility (which you already did here)
Please consider closing this thread marking the answer as best. Thank you