Copy link to clipboard
Copied
Hi All
I hope someone can help, as I have been struggling with this issue for a few days. If I have missed any useful information off of this post, please ask and I will try to supply.
I am trying to call a web service, but contantly receiving the error:
"{http://springframework.org/spring-ws}ValidationError:cvc-elt.4.3: Type 'xsd:long' is not validly derived from the type definition, 'idField', of element 'documentId'."
An example of the call to the webservice is:
<cfscript>
getDocumentAsPdfRequest = structNew();
getDocumentAsPdfRequest.documentId = 12017988;
getDocumentAsPdfRequest.ignoreUnsupportedConversion = 0;
ws = createObject("webservice", "#wsdldocumenturl#");
ws.setUsername("#wsdlusername#");
ws.setPassword("#wsdlpassword#");
myresult = ws.getDocumentAsPdf(getDocumentAsPdfRequest);
</cfscript>
<cfdump var="#myresult#">
the webservice definition is:
getDocumentAsPdfRequest type getDocumentAsPdfRequest
Id of the document to be converted to pdf
Specifying true for this will return the original document without converting - if a conversion is not possible
the webservice xml is:
<xs:element name="getDocumentAsPdfRequest">
<xs:element name="ignoreUnsupportedConversion" type="xs:boolean">
</xs:element>
I have tried using javacast("long", "12017988"), but the same error is shown
any help or advise gratefully received.
Thanks,
Darren
Copy link to clipboard
Copied
I forgot to mention that I have verified that this service works from SoapUI, the issue seams to be the way that ColdFusion is handling the documentId element.
If it is helpful the WSDL code is here (note I have only pasted the parts that are relevant to this method):
<xs:element name="getDocumentAsPdfRequest" xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:annotation>
</xs:annotation>
</xs:element>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
And the reponse:
<xs:element name="getDocumentAsPdfResponse" xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:sequence>
</xs:complexType>
</xs:element>
and the operation element:
<wsdl:operation name="getDocumentAsPdf" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
</wsdl:input>
</wsdl:output>
</wsdl:operation>
not sure if that would be helpful, but thought I would post incase.
Does anyone have any ideas as to why that error would be being generated?
Thanks,
Darren
Copy link to clipboard
Copied
What about finding a way to pass the values directly as arguments? Something along the lines of
<cfscript>
ws = createObject("webservice", "#wsdldocumenturl#");
ws.setUsername("#wsdlusername#");
ws.setPassword("#wsdlpassword#");
myresult = ws.getDocumentAsPdf(documentId,ignoreUnsupportedConversion);
</cfscript>
<cfdump var="#myresult#">
Copy link to clipboard
Copied
Hi Darren,
Could you please dump the webservice object you created ('ws') and show the dump results to us?
Copy link to clipboard
Copied
Hi BKBK and MadHumathy, and thank you for your replies.
We managed to get this resolved.
On this web service we had a custom data type 'idfield'. this was basically a long with restricted values.
When coldfusion was making the call to the service, it was adding a tag of <xsi:long> and so forcing an incorrect datatype to be passed in the xml.
For now I have removed this custom datatype and so the service accepts the long datatype that Coldfusion is forcibly supplying.
Will post back here if I find a way to prevent Coldfusion from adding this tag (and just passing the value so that the service can type cast where required), though I suspect it will be through the use of CFHTTP.
Thanks,
Darren