• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

web service call fails - type mismatch

Guest
Nov 13, 2012 Nov 13, 2012

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 

Returns the document as a pdf if possible
  • documentId type idField - type long with restriction minInclusive(1000) maxInclusive(9223372036854775807) 

Id of the document to be converted to pdf

  • ignoreUnsupportedConversion type boolean 

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:annotation> 
<xs:documentation>Returns the document as a pdf if possible</xs:documentation>
</xs:annotation>

<xs:complexType> 

<xs:sequence> 
<xs:element name="documentId" type="tns:idField"> 
<xs:annotation> 
<xs:documentation>Id of the document to be converted to pdf</xs:documentation>
</xs:annotation>
</xs:element>

<xs:element name="ignoreUnsupportedConversion" type="xs:boolean"> 

<xs:annotation> 
<xs:documentation>Specifying true for this will return the original document without converting - if a conversion is not possible</xs:documentation>
</xs:annotation>
</xs:element>

</xs:sequence>
</xs:complexType>

</xs:element>

I have tried using javacast("long", "12017988"), but the same error is shown

any help or advise gratefully received.

Thanks,

Darren

Views

989

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 14, 2012 Nov 14, 2012

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 xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:documentation xmlns:xs="http://www.w3.org/2001/XMLSchema">Returns the document as a pdf if possible</xs:documentation>

</xs:annotation>

- <xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema">

- <xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">

- <xs:element name="documentId" type="tns:idField" xmlns:xs="http://www.w3.org/2001/XMLSchema">

- <xs:annotation xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:documentation xmlns:xs="http://www.w3.org/2001/XMLSchema">Id of the document to be converted to pdf</xs:documentation>

</xs:annotation>

</xs:element>

- <xs:element name="ignoreUnsupportedConversion" type="xs:boolean" xmlns:xs="http://www.w3.org/2001/XMLSchema">

- <xs:annotation xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:documentation xmlns:xs="http://www.w3.org/2001/XMLSchema">Specifying true for this will return the original document without converting - if a conversion is not possible</xs:documentation>

</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:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema">

- <xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="content" type="xs:base64Binary" 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/"> 

<soap:operation soapAction="" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />

- <wsdl:input name="getDocumentAsPdfRequest" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />

<soap:header message="tns:credentials" part="credentials" use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />

</wsdl:input>

- <wsdl:output name="getDocumentAsPdfResponse" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2012 Nov 14, 2012

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#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2012 Nov 14, 2012

Copy link to clipboard

Copied

Hi Darren,

         Could you please dump the webservice object you created ('ws') and show the dump results to us?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 20, 2012 Nov 20, 2012

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation