2012-06-21 176 views
3

我覺得自己像一個沒有想到這個的人。我有Coldfusion webservice(bluedragon7)接受來自合作伙伴的信息。它們在結果字段中傳遞xml,它只在參數中顯示accessionNumber的第一個元素。如果我將參數類型更改爲其他任何(任何,字符串等),則會引發500個錯誤。我在這裏錯過了什麼嗎?Coldfusion Web服務接收對象

下面是函數的一個片段:

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

這裏是他們的帖子的樣本:

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

+0

我認爲您需要建模CFC以匹配XML結構,而不是將結果定義爲XML變量。按照CF指南使用複雜對象,或者如果可以,請切換到簡單的JSON Web服務而不是SOAP。 :) – Henry

+0

亨利,我發佈不消耗,並且很遺憾找不到任何有關處理這些類型的信息......您可以提供的任何參考或附加信息?謝謝! – user1473443

+0

我認爲XML總是需要**一個**根元素。因此,請嘗試傳遞由' ...'包圍的結果(accessionNumber,accountLocationCode,...)或類似的東西。 – Seybsen

回答

0

我有同樣的問題。我試圖循環所有元素,同時檢查元素是否仍然有「xmlchild」。也許我的thread可以在這裏幫助。

但是你必須改變路線,在那裏你身體的內容將被保存在一個VAR

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

剛插入「soapenv:身體」,而不是「SOAP-ENV:身體」