Hi all,
I'm trying to consume a .NET web service that has 2 arguments, one of
which is complex. The webservice is expecting an xml type and an int
type. I've looked at a lot of resources regarding this, and am still
coming up broke. I've run the wsdl against the WSDL2Java tool, and
looked at the .java file for the ws method I'm calling, and not
getting any particularly good information out of it (it wants an
argument of type _any, which from what I've read is the default .NET
signature).
>From the wsdl:
<s:element name="SOMEMETHODNAME">
−<s:complexType>
−<s:sequence>
−<s:element minOccurs="0" maxOccurs="1" name="somearg1">
−<s:complexType mixed="true">
−<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
<s:element minOccurs="1" maxOccurs="1" name="somearg2" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
Additionally, the call requires a header:
<s:element name="SecurityHeader" type="tns:SecurityHeader"/>
−<s:complexType name="SecurityHeader">
−<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SessionKey" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ClientName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string"/>
</s:sequence>
</s:complexType>
So, I've created a struct with an array for the first argument, and a
simple key for the second argument, something like so:
<cfset mystruct=structNew() />
<cfset mystruct.somearg1=arrayNew(1) />
<cfoutput query="myquery">
<cfset mystruct.somearg1[currentrow]=structNew() />
<cfset mystruct.somearg1[currentrow].EL1="#EL1#" />
<cfset mystruct.somearg1[currentrow].EL2="#EL2#" />
<cfset mystruct.somearg1[currentrow].EL3="#EL3#" />
</cfoutput>
<cfscript>
// Create the web service object.
ws = CreateObject("webservice", "http://www.domain.com/webservice.asmx?WSDL");
// Setup the SOAP header
addSOAPRequestHeader(ws, "", "SessionKey", "#variables.sessionkey#", false);
addSOAPRequestHeader(ws, "", "ClientName", "MyClientName", false);
addSOAPRequestHeader(ws, "", "UserName", "MyUserName", false);
// Invoke the web service operation.
my_result = ws.SOMEMETHODNAME(mystruct,1);
</cfscript>
I'm getting the error:
Web service operation "SOMEMETHODNAME" with parameters
{{somearg1={[{EL1={4760000-11513503999},EL2={111-222-4444},EL3={111-222-4445}...
could not be found
In the code above, I'm sending the 2nd argument via the call,
straight-up. I've also tried adding that as an key/value pair in the
struct, as in
<cfset mystruct.somearg2=1 />
and then the call would be:
my_result = ws.SOMEMETHODNAME(mystruct);
Previously I'd tried passing in the XML string, or a CF XML object as
well. I've verified that the XML format I was/am using is valid.
What am I missing? Any suggestions for fixes? A better or easier way
to approach this?
Thanks,
Kris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:286109
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4