views:

135

answers:

2

I am trying to figure out a way to consume a WCF service I have (wsdl) from Coldfusion. I need to pass values in the request header. I can't seem to find any good examples anywhere. Anyone?

A: 

In ColdFusion you can consume webservices using cfinvoke

<cfinvoke  
webservice="http://www.somewebservice.com/WebService.wsdl" 
method="getWebServiceMethod" 
returnvariable="webServiceResult"> 
<cfinvokeargument name="arg1" value="Arg1"/> 
<cfinvokeargument name="arg2" value="Arg2"/> 
</cfinvoke> 
<cfoutput>The Result is #webServiceResult#</cfoutput>

or CreateObject

<cfscript> 
ws = CreateObject("webservice",  
"http://www.somewebservice.com/WebService.wsdl"); 
webServiceResult = ws.getWebServiceMethod("Arg1","Arg2"); 
writeoutput(webServiceResult); 
</cfscript>
Andreas Schuldhaus
The key part was the "request headers". I need to send a couple values in the request header.
Brian David Berman
What kind of headers? Could you call the service via cfhttp and send headers with cfhttpparam type="header"? There is also a addSOAPRequestHeader Function but never tried it with a WCF Service.
Andreas Schuldhaus
+3  A: 

I think the functions you want is

AddSOAPRequestHeader(webservice, namespace, name, value [, mustunderstand])
AddSOAPResponseHeader(namespace, name, value[, mustunderstand])

These let you add XML to the request and response headers of your webservice.

Ben Doom
Edward M Smith