簡體   English   中英

在SOAP調用中傳遞PHP數組

[英]Passing a PHP array in a SOAP call

因此,我試圖在我的SOAP請求中包括以下XML:

<Responses>
    <Response>
        <QuestionAnswerID>someint</QuestionAnswerID>
        <QuestionID>someint</QuestionID>
    </Response>
    <Response>
        <QuestionAnswerID>someint</QuestionAnswerID>
        <QuestionID>someint</QuestionID>
    </Response>
</Responses>

我看了一下這個帖子, 這個帖子含糊地涉及同一主題,但它產生的輸出如下:

object(stdClass)#1 (1) {
    ["Responses"]=>
    object(stdClass)#2 (1) {
        ["Response"]=>
        array(2) {
            [0]=>
            object(stdClass)#3 (2) {
                ["QuestionAnswerID"]=>
                int(someint)
                ["QuestionID"]=>
                int(someint)
            }
            [1]=>
            object(stdClass)#4 (2) {
                ["QuestionAnswerID"]=>
                int(someint)
                ["SurveyQuestionID"]=>
                int(someint)
            }
        }
    }
}

問題在於,數組現在具有索引,我正在調用的Web服務似乎不喜歡該索引。 有什么辦法可以生成類似上述XML的內容嗎?

TIA。

沒有WSDL的SOAP服務器,很難進行測試。 您應該能夠像這樣創建關聯數組:

$responses = array();
$responses[] = array("QuestionAnswerID" => someint, "QuestionID" => someint);
$responses[] = array("QuestionAnswerID" => someint, "QuestionID" => someint);

$response = array("Response" => $responses);

$soapData = array("Responses" => $response);

暫無
暫無

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

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