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:

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

$client=new SoapClient('',
                       array('features' => SOAP_SINGLE_ELEMENT_ARRAYS));

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

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 利用Java连接API接口总是出问题
  • ¥15 请教一个关于镜头标定,棋盘格格子大小的问题(畸变测试)
  • ¥15 el-table输入多维数组怎么实现
  • ¥15 安装GroudingDINO RuntimeError: Error compiling objects for extension
  • ¥15 关于推送项目到github的问题
  • ¥15 急!C++指针编写相关的问题
  • ¥15 kerberos身份认证配置问题
  • ¥30 用python写一个多签情况下波场的代理资源和回收资源
  • ¥15 怎么在matlab中输出显示泵的流量-扬程和管路损失与流量均在一个表格里
  • ¥15 matlab学期例题代码答疑