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

Can CF do Custom Web Service Headers?

Advocate ,
Oct 16, 2008 Oct 16, 2008

Copy link to clipboard

Copied

I am trying to consumer a web service created in .NET that appears to use a custom Header object for authentication. I'm banging my head against the wall trying to figure out how to configure the WS invoke from CF so that it creates the correct SOAP.

Normally I would try and create a CF Structure and pass it into the web service call.
e.g.:

objWS = CreateObject("webservice", " http://www.somesite.com/webservices/myMethod.asmx?WSDL");

myAuthHeader = {username="user1",password="pass1"};

addSOAPRequestHeader(obj, " http://www.somesite.com/webservices/", "AuthenticationHeader", myAuthHeader);


But that gives me the following result:

<soapenv:Header>
<ns1:AuthenticationHeader soapenv:mustUnderstand="true" soapenv:role=" http://schemas.xmlsoap.org/soap/actor/next" xmlns:ns1=" http://www.somesite.com/webservices/">
<item xmlns:ns2=" http://xml.apache.org/xml-soap">
<key xsi:type="xsd:string">USERNAME</key>
<value xsi:type="xsd:string">user1</value>
</item>
<item>
<key xsi:type="xsd:string">PASSWORD</key>
<value xsi:type="xsd:string">pass1</value>
</item>
</ns1:AuthenticationHeader>
</soapenv:Header>

Instead of:

<soap:Header>
<AuthenticationHeader xmlns=" http://www.somesite.com/webservices/">
<UserName>user1</UserName>
<Password>pass1</Password>
</AuthenticationHeader>
</soap:Header>

Anyone have an ideas on what I'm doing wrong?

Thanks!
TOPICS
Advanced techniques

Views

331

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

correct answers 1 Correct answer

Advocate , Oct 16, 2008 Oct 16, 2008
Wouldn't you know it - after searching/attempting for hours to try and figure it out, I stumbled over the solution about 10 minutes after posting this. For anyone interested, the answer can be found here:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=webservices_24.html

The secret - create your custom element as an XML string, parse it into an object and then pass it to your webservice using the addSOAPRequestHeader function:

<cfsavecontent variable="myXML">
<Authenticat...

Votes

Translate

Translate
Advocate ,
Oct 16, 2008 Oct 16, 2008

Copy link to clipboard

Copied

LATEST
Wouldn't you know it - after searching/attempting for hours to try and figure it out, I stumbled over the solution about 10 minutes after posting this. For anyone interested, the answer can be found here:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=webservices_24.html

The secret - create your custom element as an XML string, parse it into an object and then pass it to your webservice using the addSOAPRequestHeader function:

<cfsavecontent variable="myXML">
<AuthenticationHeader xmlns=" http://www.somesite.com/webservices/">
<UserName>user1</UserName>
<Password>pass1</Password>
</AuthenticationHeader>
</cfsavecontent>
<cfset xmlObj = xmlParse(myXML)>

...

addSOAPRequestHeader(objWS, " http://www.somesite.com/webservices/", "AuthenticationHeader", xmlObj);

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