传递一个PHP数组中的一个SOAP调用 [英] Passing a PHP array in a SOAP call

查看:229
本文介绍了传递一个PHP数组中的一个SOAP调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想包括我的SOAP请求以下XML:

So I am trying to include the following XML in my SOAP request:

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

我看着这个发布,这是隐约的同样的话题,但它产生的输出像这样:

I looked at this posting, which is vaguely on the same topic, but it produces output like so:

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?

The problem with that is that the arrays now have indices, which the web service I'm calling appears to not like. Any way I can generate something like the above XML?

TIA。

推荐答案

这是很难测试此而不与WSDL去反对一个SOAP服务器。您应该能够创建关联数组,像这样:

It's hard to test this without a SOAP server with your WSDL to go against. You should be able to create associative arrays like so:

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

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

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

这篇关于传递一个PHP数组中的一个SOAP调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆