dongnan1989 2010-03-16 18:21
浏览 252
已采纳

PHP SoapClient()函数返回单个XML字符串

I am having difficulty with the PHP SoapClient() function. The SOAP request is successful, but the response is returned as an object containing a single XML string with the key "any". For example:

<?php
$params = array('strUsername' => 'Test',
                'strPassword' => 'Test');

$client=new SoapClient('http://www.example.com/webservice.asmx?wsdl',
                       array('features' => SOAP_SINGLE_ELEMENT_ARRAYS));

$result = $client->strExampleCall($params);
print_r($result);
?>

This outputs the following:

stdClass Object
(
    [strExampleCallResult] => stdClass Object
    (
        [any] => <Response xmlns="" release="1.0.0" environment="Production" lang="en-GB"><ApplicationArea><Sender><SenderId>0</SenderId><ReferenceId>0</ReferenceId></Sender><Destination><DestinationId>1</DestinationId></Destination></ApplicationArea><DataArea><Result>1</Result></DataArea></Response>
    )
)

Subsequently, I cannot access properties of the object as I'd expect to:

echo $result->strExampleCallResult->Response->DataArea->Result;

Why isn't PHP parsing the SOAP response into properties of the returned object?

I am using PHP 5.3.0 and believe the SOAP server is running .NET.

  • 写回答

1条回答 默认 最新

  • dpntq48842 2010-03-17 22:36
    关注

    I have now solved this.

    The third party SOAP server was designed to return data in XML format, nested within the SOAP response. I am now parsing the XML response with SimpleXML.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题