5 Replies Latest reply on Jul 20, 2010 8:43 PM by mjrjweb

    How to use SOAP in ColdFusion

    Dileep_NR Level 2

      Hi All,


      The code set am using as follows

      <cfsavecontent variable="soap">
      <?xml version="1.0" encoding="UTF-8"?>
              xmlns="http://one.dileep.com/soaptest/"><!---1 this is the cfc location--->


          <!--- 2 header param --->
              <addNumbers soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
              <!---3 cfc method name --->


      <cfhttp url="http://one.dileep.com/soaptest/soaptest.cfc" method="post">
          <cfhttpparam type="header" name="content-type" value="text/xml">
          <cfhttpparam type="header" name="SOAPAction" value="">
          <cfhttpparam type="header" name="content-length" value="#len(soap)#">
          <cfhttpparam type="header" name="charset" value="utf-8">
          <cfhttpparam type="xml" name="message" value="#trim(soap)#">


      <cfdump var="#xmlparse(cfhttp.FileContent)#">


      <cfcomponent output="false" >
          <cffunction name="addNumbers" access="remote" returntype="any" output="false">
              <cfargument name="firstNumber" type="string" required="true"/>
              <cfargument name="secondNumber" type="string" required="true"/>
              <cfset retunVal="NO">
              <cfset username=0>
              <cfif isSOAPRequest()>           
                  <cfset username = getSOAPRequestHeader("http://one.dileep.com/soaptest/", "setInit")>
                  <!---4 retrieving  SOAP header value --->
              <cfreturn arguments.firstNumber + arguments.secondNumber & username   />





      This is the right way for implimenting SOAP in COLDFUSION webservice ?


      More Questios


      1- <!---1 this is the cfc url--->


      What is the relevance of the cfc URL ? I am using sub domains

      eg : one.dileep.com, two.dileep.com,yyy.dileep.com, in this case the cfc url 'http://<<subdomain>>.dileep.com/soaptest/' should changed accordingly?


      2-<!--- 2 header param --->

      We have to give any tag name as Header?


      3- <!---3 cfc method name --->

      SOAP body  tag must be the method name that we need to exicute?

      Here, I have to execute method 'addNumbers'


      4- <!---4 retrieving  SOAP header value --->

      While retrieving the header value should we need to specify the cfc url?('http://<<subdomain>>.dileep.com/soaptest/')



      Please help.