3

I feel like a dolt for not figuring this one out. I have coldfusion webservice (bluedragon7) to accept information from a partner. They are passing xml in the result field and it only shows the first element of accessionNumber in the argument. If I change the argument type to anything else (any, string etc), it throws 500 errors. Am I missing something here?

Here is a snippet of the function:

<cffunction access="remote" name="result" output="false" returntype="any" hint="">
<cfargument name="userid" type="string" required="yes" hint="userid">
<cfargument name="password" type="string" required="yes" hint="password">
<cfargument name="result" type="xml" required="Yes" default="result">
</cffunction>  

Here is a sample of their post:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header />
<soapenv:Body>
    <result xmlns="http://cws.ots.labcorp.com">
        <userId>peter265974</userId>
        <password>pwd265974</password>
        <result>
            <accessionNumber>0572854881</accessionNumber>
            <accountLocationCode>000010</accountLocationCode>
            <accountLocationName>AERO CONTROL</accountLocationName>
            <accountLocationPhone>2537353350</accountLocationPhone>
            <accountName>HEALTHFORCE PARTNERS CORPORATE</accountName>
            <accountNumber>000804</accountNumber>
            <collectorCOCcomments>
                <abbreviation />
                <commentText>100154550. TEST OF VIEWING CO</commentText>
                <commentType>MS</commentType>
            </collectorCOCcomments>
        </result>
    </result>
</soapenv:Body>

user1473443
  • 133
  • 1
  • 5
  • I think you need to model your CFC to match the XML structure, instead of just defining result as a XML variable. Follow the CF guide for consuming complex object, or if you can, switch to a simple JSON webservice instead of SOAP. :) – Henry Jun 21 '12 at 23:27
  • Henry, I'm publishing not consuming, and unfortunately couldn't find any information on handling these types......Any references or additional information you could provide? Thanks! – user1473443 Jun 22 '12 at 04:47
  • I think XML always needs **one** root element. So try passing the result (accessionNumber, accountLocationCode,...) surrounded by `...` or something like that. – Seybsen Jun 22 '12 at 11:36
  • Unfortunately their side is standard and cannot be changed. They are using java and passing it as an object.....so, how can I receive this object in coldfusion? – user1473443 Jun 24 '12 at 17:21

1 Answers1

0

I just had the same problem. I tried to loop over all elements while checking if the element still had "xmlchild". Maybe my thread can help here.

But you have to change the line, where the content of your body will be saved in a var

<cfset var body = xmlsearch(cont, "//SOAP-ENV:Body")[1] />

just insert "soapenv:Body" instead of "SOAP-ENV:Body"

Community
  • 1
  • 1
Alex Cio
  • 6,014
  • 5
  • 44
  • 74