簡體   English   中英

返回Soap服務器php的soap xml響應

[英]returning soap xml response for a soap server php

我正在嘗試使用本機php soap服務器在php中創建一個soap服務。 我已經准備了wsdl文件。 soap服務基本上可以調用四種方法。 請求ShowRemittanceDetail之一的輸入soap請求如下所示。

<soap-env:body>
    <ns1:showremittancedetailrequest>
        <username>admin</username>
        <password>pass</password>
        <refno>USA1956127848</refno>
    </ns1:showremittancedetailrequest>
</soap-env:body>

無論如何,soap請求沒有標題,而我剛剛在此處顯示了正文。 我解析肥皂請求沒有問題。 響應應如下所示

<?xml version="1.0" encoding="ISO-8859-1"?>
<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">
    <soapenv:Body>
    <ns2:responseType xmlns:ns2="http://tempuri.org/response">
        <code>00</code>
        <message>Transaction does not exist or is not available</message>
        <responseBody>
            <responseStr>4</responseStr>
        </responseBody>
    </ns2:responseType>
    </soapenv:Body>
</soapenv:Envelope>

這是當服務器中沒有帶有參考號的交易時生成的特定響應。 我已經收到了肥皂請求並進行了評估。 但是我對肥皂響應的返回類型有疑問。 我無法生成有效的回復。 肥皂服務器應返回哪種類型的響應?

我嘗試過的事情:

  1. 我嘗試返回xml字符串。 但是soap客戶端請求將引發以下消息異常。 looks like we got no xml document
  2. 我也嘗試過以相同的結果重播本機php SoapVar()

  3. 我嘗試返回在皂類服務器的類映射中指定的對象響應。 例如,對於上面的示例,我嘗試返回具有相同結果的ShowRemittanceDetailResponse對象。 looks like we got no xml document )。

  4. 我試圖返回一個DomDocument對象。 在這種情況下拋出的異常是

the encoded object does not have a responseStr property

  1. 我嘗試返回一個stdClass對象,該對象的字段與響應期望的字段相同,並且結果相似。

請幫我。 提前致謝。

我發現的解決方案是返回SoapVar對象。 我沒有soapui,我在php中編寫的客戶端不正確。 因此,由於php soap客戶端拋出異常,我無法驗證返回的xml。 對我來說正確的方法是返回SoapVar。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM