> did you ever get this figured out? I am coming across the same thing

Hi Shane,

I did find an approach that works for my situation. Here are some
abbreviated notes I put together for our team:

Note, you'll need to access the WSDL file, and soap descriptions for
your webservice calls.

Cheers,
Kris

-----------------------------------------
ColdFusion has the ability to consume (e.g., call) a webservice using
it's CFINVOKE and CFINVOKEARGUMENT tags:

<cfinvoke
    webservice="webservice wsdl address"
    method="ws method name"
    returnvariable="myreturnvar">
        <cfinvokeargument name="ws parameter name 1" value="my param value" />
        <cfinvokeargument name="ws parameter name 2" value="my param value" />
</cfinvoke>

You can also wrap the arguments up in the cfinvoke tag itself, like this:

<cfinvoke
    webservice="webservice wsdl address"
    method="ws method name"
    parametername1="my param value"
    parametername2="my param value"
    returnvariable="myreturnvar" />

Be aware that ColdFusion has, in it's CFInvoke tag, parameters called
username and password. If the web service you are calling has
attributes with these same names, your web service call will not work
if you are using the simple form of CFInvoke like this:

<cfinvoke
    webservice="webservice wsdl address"
    method="ws method name"
    username="myusername"
    password="mypassword"
    attributeN="value"
    returnvariable="myreturnvar" />

You must create a structure to hold your attributes, and pass that in
the attributeCollection parameter instead:

<cfset stArgs=structNew() />
<cfset stArgs.username="myusername" />
<cfset stArgs.password="mypassword" />
<cfset stArgs.attributeN="value" />

<cfinvoke
    webservice="webservice wsdl address"
    method="ws method name"
    attributeCollection="#stArgs#"
    returnvariable="myreturnvar" />

In general, when you are dealing with complex inputs to a webservice,
you are probably better off just constructing the soap packet
manually, and calling the webservice via cfhttp, rather than
attempting to use cfinvoke on a webservice object, for example:

<cfsavecontent variable="soap_packet"><cfoutput><?xml version="1.0"
encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<soap:Header>
    <HeaderName xmlns="name_space_address">
        <headerparam1>#variables.sessionkey#</headerparam1>
        <headerparam2>ImpExpTestClient</headerparam2>
        <headerparam3>xmlservices</headerparam3>
    </HeaderName>
</soap:Header>
<soap:Body>
    <PN_SET_VENDORCOMBO xmlns="name_space_address">
        <webserviceparam1>#variables.xmlstring#</webserviceparam1>
        <webserviceparam2>#request.integration_package_id#</webserviceparam2>
    </PN_SET_VENDORCOMBO>
</soap:Body>
</soap:Envelope>
</cfoutput>
</cfsavecontent>

<cfhttp url="webservice_wsdl_address" method="POST">
<cfhttpparam type="HEADER" name="Content-Type" value="text/xml; charset=utf-8">
<cfhttpparam type="HEADER" name="Accept" value="application/soap+xml,
application/dime, multipart/related, text/*">
<cfhttpparam type="HEADER" name="User-Agent" value="Axis/1.1">
<cfhttpparam type="HEADER" name="Host" value="dotted_notation_host_address">
<cfhttpparam type="HEADER" name="Cache-Control" value="no-cache">
<cfhttpparam type="HEADER" name="Pragma" value="no-cache">
<cfhttpparam type="HEADER" name="SOAPAction" value="URL TO WEBSERVICEorMETHOD">
<cfhttpparam type="HEADER" name="Content-Length"
value="#len(trim(soap_packet))#">
<cfhttpparam type="BODY" value="#trim(soap_packet)#">
</cfhttp>

In the cfhttp call above, note the URL, Host, SOAPAction,
Content-Length, and BODY are dependent on your call. Everything else
can remain static as shown.

Also, when receiving complex structures back from a webservice call,
remember that CFDUMP is your friend. When using CFINVOKE, very often
the return value is inside an object returned by the web service. With
our webservices, usually, you'll need to call the get_any() function
on the object to get the actual return value. Which function is to be
called is dependent on the type of value being returned, and certainly
can be webservice method specific. The results from the get_any() (or
whatever) call, will usually be an array--but not always--so again,
CFDUMP is your friend.

Finally, here are decent articles on consuming web services from/to .Net:
http://coldfusion.sys-con.com/read/47199.htm

Long forum discussion on consuming complex web services that require
specific header and property attributes:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=7&threadid=781179

And finally, here is an article on the nitty-gritty behind how
ColdFusion utilizes Java to interface with most other web services,
specifically having to do with complex web services, and how we get
our type-less values to be typed correctly for the web-service being
called. It's not inherently necessary to read it, but it is good
information:

When having to pass complex structures into a .Net webservice, read
this excellent article, which you'll have to get from the WayBack
machine, because it's no longer available on the authors' website:
http://web.archive.org/web/20070309173903/http://hcc.musc.edu/research/shared_resources/xml_complex_types_to_cf_structure_notes.cfm

And, while this article gives some approaches for dealing with complex
calls, I still found that just writing the soap packet manually got me
the results (and more easily).
-----------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:287940
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to