• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with AddSOAPRequestHeader method

New Here ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

I have the following XML that i need to add to the SOAP header before calling a webservice that is using WS-Security (hence the added headers)

<wsse:Security soap:mustUnderstand="1">
<wsu:Timestamp wsu:Id="Timestamp-15360f9f-15f3-466d-a27f-b7f0712304d6">
<wsu:Created>2006-10-05T13:59:31Z</wsu:Created>
<wsu:Expires>2006-10-05T14:04:31Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken wsu:Id="SecurityToken-d1370982-78d0-42f6-b4c8-1b2436005cde">
<wsse:Username>myusername</wsse:Username>
<wsse:Password Type=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myp...
<wsse:Nonce>pUs9fli84lbLpac5hJ3K4g==</wsse:Nonce>
<wsu:Created>2006-10-05T13:59:31Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>

How do i add this using the AddSOAPRequestHeader?
I tried creating an XML object and send that, but XMLParse keeps telling that a 'wss' namespace isnt defined, when i add that
it cries about the "soap:envelope" namespace and so on.

Im clueless how to use AddSOAPRequestHeader here since much of these are attributes to tags and not just values

please help
TOPICS
Advanced techniques

Views

667

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 28, 2007 Mar 28, 2007

Copy link to clipboard

Copied

Did you ever figure out how to do this? I have the same question.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 02, 2007 Jun 02, 2007

Copy link to clipboard

Copied

I don't know if this is the best way to do it, but after much trial and error, I've come up with something that works.

<cfscript>
myObj = createObject("webservice","path/to/wsdl");
headerElement = createObject("java", "org.apache.axis.message.SOAPHeaderElement");
headerElement.init(" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:Security");
headerElement.addChildElement("wsse:UsernameToken");
headerElement.getFirstChild().addChildElement("wsse:Username").setValue(myUsername);
headerElement.getFirstChild().addChildElement("wsse:Password").setValue(myPassword);
headerElement.setMustUnderstand(1);
myObj.setHeader(headerElement);
</cfscript>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2007 Jun 04, 2007

Copy link to clipboard

Copied

Thanks for sharing this. Maybe it can help me eventually. Unfortunately, the wsdl for the webservice I'm trying to consume includes the following under <wsdl:definitions... />:

xmlns:ns8=" http://www.w3.org/2000/09/xmldsig#"

For some reason, this prevents me from even instantiating the webservice. The error I get is:

Could not generate stub objects for web service invocation.... java.io.IOException: Type { http://www.w3.org/2000/09/xmldsig#} Reference is referenced but not defined.

I'm guessing that there is either some Java library I need, or CF is barfing on the #. Anyway, I never get far enough to add the headers.

Ideas from anyone on resolving this part of my problem would be most welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

LATEST
DonnaB,

You can try hosting the wsdl on your local machine, which would allow you to play around with the actual contents (try removing the # sign, or using a different URL for ns8?). As long as the wsdl has a service port element pointing to the actual webservice URL it doesn't actually matter where the WSDL file resides.

If this is the way you decide to go, I would recommend a scheduled task that downloads the ACTUAL WSDL file on a regular basis, makes the changes and then saves it locally to make sure you are using the latest version.

Also, this issue seems unique enough that it really should have its own thread. Post to a new topic - you'll probably get a lot more suggestions

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation