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.
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.