Skip to main content
Participant
December 19, 2012
Question

SOAP cfhttpparam header syntax

  • December 19, 2012
  • 1 reply
  • 497 views

I have been working for days trying to figure out this web service header issue.

Format I need to send Header in:

<soap:Header>

<wsse:Security soap:mustUnderstand="1">

  <wsse:UsernameToken namespaces>

            <wsse:Username>username</wsse:Username>

            <wsse:Password Type="type info">password</wsse:Password>

            <wsse:Nonce>nonce</wsse:Nonce>

            <wsu:Created>date created</wsu:Created>

        </wsse:UsernameToken>

    <wsse:Security>

</soap:Header>

What I have

<cfsavecontent variable="soapHeader">

    <cfoutput>

    <soap:Header>

        <wsse:Security soap:mustUnderstand="1">

            <wsse:UsernameToken namespaces>

                <wsse:Username>myUsername</wsse:Username>

                <wsse:Password Type="type info">myPassword</wsse:Password>

                <wsse:Nonce>blahblah</wsse:Nonce>

                <wsu:Created>2012-12-18</wsu:Created>

            </wsse:UsernameToken>

        <wsse:Security>

    </soap:Header>

    </cfoutput>

</cfsavecontent>

<cfhttp

    method="post"

    url="https://Website.asmx?wsdl"

    result="httpResponse">

    <cfhttpparam

     type="header"

     name="Security"

        value="#trim( soapHeader )#"/>

    <cfhttpparam

    type="body"

        value="#trim( soapBody )#"/>

</cfhttp>

It's connecting to the destination but my header syntax isn't correct. I feel like I should be using cfhttpparam's to include the header data, but I'm not sure of the syntax I should be using there.  Because in the 'Format I need to send Header in' it's written like 'wsse:Security' and within that 'wsse:UsernameToken namespaces'.

How do I format my httpparams to include my fields correctly?

I tried :

cfhttpparam

     type="header"

     name="Security:UsernameToken"

But it didn't work.

Any help would be appreciated.

Thank you.

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    December 19, 2012

    <cfhttpparam type="header"> identifies a header to the web service. So you might be duplicating things when you use it to send <soap:Header> ...</soap:Header>. Try sending it as XML type, thus

    <cfhttpparam

        type="xml"

        name="Security"

        value="#trim(soapHeader)#"/>