通过SOAP调用传递PHP数组

3

我正在尝试在我的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)
            }
        }
    }
}

问题在于这些数组现在有了索引,而我调用的网络服务似乎不喜欢它们。有什么方法可以生成类似上面的XML吗?

TIA。


有人刚刚在我的问题下发布了这个链接:http://meta.stackexchange.com/questions/686/… ;) - Chris Williams
谢谢..我之前没有做过那个。猜我现在就开始吧。 - Chris Williams
1个回答

10

如果没有一个带有你的WSDL的SOAP服务器进行测试是很困难的。你应该能够像这样创建关联数组:

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

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

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接