2 Replies Latest reply on Oct 9, 2007 8:42 AM by Skemcin

    CF and Web Service Header content

      Hi all, here is some code I am using to successfully consume a web service:


      <cfinvoke webservice=" http://mydomain/myservice.asmx?wsdl"
      <cfinvokeargument name="userName" value="xxxxxx"/>
      <cfinvokeargument name="password" value="xxxxxx"/>
      <cfdump var="#wstoken#" label="MyMethod" /><br />

      Get everything back as I would suspect, as far as the <soap:body> of the SOAP is concerned. But this also has information in the <soap:header> that I need to extract.

      The <cfinvoke> method of consuming the web service doesn't provide that information - or if it does I do not know how.

      I've google stuff all day and I only get examples that fail when I try to implement them or they are from 2003 or 2005. I'm confused/unsure as to how to use all the ColdFusion SOAP functions list here:

      So, The stuff I am building is not that complex so I am ok with dynamically building all the SOAP in <cfsavecontent> and then sending and receiving the raw information - but I can't figure that out either.

      I'm now brain blocked - I've temporarily convinced myself I am not able to resolve this as my searches and attempts to fix it are becoming repetitious.

      Any help would be greatly appreciated - just let me know what other information (code) you will need to see and I'll post it.

      Thanks in advance.
        • 1. Re: CF and Web Service Header content
          <!--- Create Web Service --->
          <cfset ws = CreateObject("webservice", " http://mydomain/myservice.asmx?wsdl") />

          <!--- Consume Web Service --->
          <cfset x = ws.MethodToCall(username, password) />

          <cfset addSOAPRequestHeader(ws, " http://www.framingeinstein.com/", "header1", "value1", false) />
          <cfset addSOAPRequestHeader(ws, " http://www.framingeinstein.com/", "header2", "value2", false) />

          <!--- Retrieve Headers (returns an array of org.apache.axis.message.SOAPHeaderElement Objects --->
          <cfset y = ws.getHeaders() />
          <!--- Could use GetSoapResponseHeader function if you know the name and namespaces of the header values --->

          <!--- Process Response Headers --->
          HeaderName = HeaderValue <br />
          <cfloop from="1" to="#ArrayLen(y)#" index="i">
          <cfoutput>#y .getNodeName()# = #y.getValue()#</cfoutput>

          This would be one way to do it.
          • 2. Re: CF and Web Service Header content
            Skemcin Level 1
            Half way there. This will successfully get the soap header value that I need.

            <cfset nfws_address=" http://www.yourdomain.com/xxxxxx.xxx?wsdl">
            <cfset nfws_namespace=" http://www.yourdomain.com/xxxxxx/">
            <cfset nfws_uname="xxxxxx">
            <cfset nfws_pword="xxxxxx">

            <cfset nfws_method="xxxxxx">
            <cfset nfws_token="">

            ws = CreateObject("webservice",nfws_address);
            ws.Authenticate(userName = nfws_uname, password = nfws_pword);
            nfws_token = getSOAPResponseHeader(ws,nfws_namespace,nfws_method, true);

            <cfcatch type="any">
            <cfset ws_token="Something Failed">
            <cfdump var="#nfws_token#">

            Next, see if I can add the token to the next web service call I need to make...