How to use SOAP in ColdFusion
Hi All,
The code set am using as follows
--------
index.cfm
--------
<cfsavecontent variable="soap">
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://one.dileep.com/soaptest/"><!---1 this is the cfc location--->
<soapenv:Header>
<setInit>1</setInit>
<!--- 2 header param --->
</soapenv:Header>
<soapenv:Body>
<addNumbers soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<!---3 cfc method name --->
<firstNumber>1000</firstNumber>
<secondNumber>10</secondNumber>
</addNumbers>
</soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>
<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)#">
</cfhttp>
<cfdump var="#xmlparse(cfhttp.FileContent)#">
-------------
soaptest.cfc
-------------
<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 --->
</cfif>
<cfreturn arguments.firstNumber + arguments.secondNumber & username />
</cffunction>
</cfcomponent>
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.
