【问题标题】:Passing a PHP array in a SOAP call在 SOAP 调用中传递 PHP 数组
【发布时间】:2009-08-27 02:32:49
【问题描述】:

所以我试图在我的 SOAP 请求中包含以下 XML:

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

我查看了this 的帖子,它模糊地涉及同一主题,但它产生的输出如下:

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。

【问题讨论】:

标签: php xml arrays soap


【解决方案1】:

如果没有 SOAP 服务器与您的 WSDL 对抗,很难对此进行测试。您应该能够像这样创建关联数组:

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

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

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

【讨论】:

    猜你喜欢
    • 2010-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-25
    • 1970-01-01
    • 2017-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多