Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Service refuses to invoke

Status
Not open for further replies.

SpotsyRWH

Programmer
Dec 2, 2005
11
0
0
US
I have a web service that requires an array of complex objects to be sent to it. When I try to invoke this specific service cold fusion simply tells me that it was unable to do it, and does not return any information as to what was the problem, just "Could Not invoke webservice GetDocuments". I beleive that I am formating the cold fusion structure and array correctly, however this is my first time sending a complex object to a web service.

Here is the snippet from the WSDL:

<xsd:complexType name="SearchParameterValue">
- <xsd:sequence>
<xsd:element name="Id" nillable="true" type="xsd:string" />
<xsd:element name="Value" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="ArrayOfSearchParameterValue">
- <xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="SearchParameterValue" nillable="true" type="tns:SearchParameterValue" />
</xsd:sequence>
</xsd:complexType>
- <xsd:element name="GetDocuments">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element name="UserName" nillable="true" type="xsd:string" />
<xsd:element name="ShortcutId" nillable="true" type="xsd:string" />
<xsd:element name="SearchParameterValue" nillable="true" type="tns:ArrayOfSearchParameterValue" />
<xsd:element name="CountOnly" type="xsd:boolean" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>

It would seem to be that I need to create an array, set each array item to a structure, and then pass through it and assign the ID and Value information.

Here is my code:

<cfset AgendaID="V2ViU2VhcmNofkFnZW5kYVhNTFdlYlNlYXJjaA==">

<cfset startingDateRange=Dateformat(DateAdd("m",-6,now()),"MM/DD/YYYY")>
<cfset endingDateRange=Dateformat(now(),"MM/DD/YYYY")>
<cfset documentStartDate=Dateformat(DateAdd("m",-6,now()),"MM/DD/YYYY")>
<cfset documentEndDate=Dateformat(now(),"MM/DD/YYYY")>

<cfset ParamValues=Arraynew(1)>

<cfset ParamValues[1] = StructNew()>
<cfset ParamValues[1].Value = startingDateRange>
<cfset ParamValues[1].Id="U3RhcnRpbmcgRGF0ZSBSYW5nZQ==">

<cfset ParamValues[2] = StructNew()>
<cfset ParamValues[2].Value = endingDateRange>
<cfset ParamValues[2].Id="RW5kaW5nIERhdGUgUmFuZ2U=">

<cfset ParamValues[3] = StructNew()>
<cfset ParamValues[3].Value = documentStartDate>
<cfset ParamValues[3].Id="RG9jdW1lbnQgU3RhcnQgRGF0ZQ==">

<cfset ParamValues[4] = StructNew()>
<cfset ParamValues[4].Value = documentEndDate>
<cfset ParamValues[4].Id="RG9jdW1lbnQgRW5kIERhdGU=">

<cfinvoke webservice="VendorWebService" method="GetDocuments" returnvariable="Testing">
<cfinvokeargument name="UserName" value="ThatsASecret">
<cfinvokeargument name="ShortcutID" value="#AgendaID#">
<cfinvokeargument name="SearchParameterValue" value="#ParamValues#">
<cfinvokeargument name="CountOnly" value="false">
</cfinvoke>

when I run this code I am simply provided with "Could not perform web service invocation "GetDocuments"." Talking to the vendor it seems to be that I am sending the correct data, however I beleive I might have to rearrange the data some how before sending it to the web service. I've reviewed the CF documentation on this, and it would appear that I am doing it right, unless I am missing something.

I am running CF7 fully patched, and I am able to call other services from this same WSDL fine, however they do not require complex objects.
 
I turned off my custom server error page in cold fusion and it gave me more information (Don't know why it did'nt do it before with debugging enabled).

However it is still telling me what I thought was the problem, however I don't see how the data types don't match.

---------------------------------------------------

Could not perform web service invocation "GetDocuments".
Here is the fault returned when invoking the web service operation:

java.lang.IllegalArgumentException: argument type mismatch

 
I have setup a sniffer to confirm this, but the error is being thrown by cold fusion and not by the web service. In fact my data is not even attempted to be sent to the web service via cold fusion.

So cold fusion does like how I have one or more of the parameters formated. However I do not see what is wrong with the format. Can anyone provide some insight into this?
 
i think your error happens due to this line

<cfinvokeargument name="SearchParameterValue" value="#ParamValues#">

SearchParameterValues is an array and you pass a struct.

hope it helps...

 
I think it has something to do with that too, however I am creating an array and setting each array index to a new structure.

<cfset ParamValues=Arraynew(1)>

<cfset ParamValues[1] = StructNew()>

... etc

I would think that this would create an array of structures, which I think is what SearchParameterValues wants.

Based on a CFDump of ParamValues it looks how I am expecting it to. (This probably is'nt going to look right when I paste it here)

Code:
array  
1 struct 
  ID U3RhcnRpbmcgRGF0ZSBSYW5nZQ==  
  VALUE 07/04/2005  
 
2 struct 
  ID RW5kaW5nIERhdGUgUmFuZ2U=  
  VALUE 01/04/2006  
 
3 struct 
  ID RG9jdW1lbnQgU3RhcnQgRGF0ZQ==  
  VALUE 07/04/2005  
 
4 struct 
  ID RG9jdW1lbnQgRW5kIERhdGU=  
  VALUE 01/04/2006
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top