views:

536

answers:

2

I have a problem with a Coldfusion webservice I've created. The service accepts XML data, BASE64 encoded, and then writes it to disk for archive purposes. This file then undergoes a basic schema check and any errors are reported back to the user as follows:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    <soapenv:Body>
     <UploadXMLResponse xmlns="http://url"&gt;
      <UploadXMLReturn>
       <AuthMessage>Authentication successful</AuthMessage>
       <AuthStatus>Success</AuthStatus>
       <FileInfo>File Example.xml was successfully uploaded</FileInfo>
       <UploadStatus>Success</UploadStatus>
       <xmlValErrors>
        <xmlValErrors xsi:type="xsd:string">1824</xmlValErrors>
        <xmlValErrors xsi:type="xsd:string">Error Message</xmlValErrors>
        <xmlValErrors xsi:type="xsd:string">23</xmlValErrors>
        <xmlValErrors xsi:type="xsd:string">1824</xmlValErrors>
        <xmlValErrors xsi:type="xsd:string">Error Message</xmlValErrors>
        <xmlValErrors xsi:type="xsd:string">38</xmlValErrors>
       </xmlValErrors>
       <xmlValMessage>Schema validation generated errors</xmlValMessage>
       <xmlValStatus>Failure</xmlValStatus>
      </UploadXMLReturn>
     </UploadXMLResponse>
    </soapenv:Body>
</soapenv:Envelope>

The problem is that the <xmlValErrors> element is nested in a slightly weird way. This is due to the way Coldfusion handles the array of errors. The result is that when a user tries to analyse the reponse, they are only able to see the initial <xmlValErrors> element.

.Net appears to be a particular problem here, as it sees the <xmlValErrors> element as an empty array, even although it clearly contains numerous other elements.

I suspect the problem lays with the reuse of the name on the child elements within the <xmlValErrors> element. However I have not been able to find a way around this in Coldfusion.

Thoughts on how this might be resolved would greatly appreciated.

+1  A: 

Neither XML nor SOAP are my strong suit, but should not the sub-elements of xmlValErrors not also be called "xmlValErrors". Don't you want them each to be "xmlValError"?

Al Everett
Al, that is precisely my problem. I'm hoping someone can answer it from either the perspective of dealing with the way Coldfusion structures the output. Or by offering a solution which allows .Net to see the child elements, even although they are so annoyingly named.
Neil Albrock
+2  A: 

How were you accessing xmlValErrors? Because your array of errors is inside the parent xmlVarErrors, you want to access it like so:

uploadxmlreturn.xmlvarerrors.xmlvarerrors

The first xmlvarerrors points to the parent, the second to the array of errors.

Make sense?

CF Jedi Master