【问题标题】:Read Array Object from WSDL XML with namespaces in PHP使用 PHP 中的命名空间从 WSDL XML 读取数组对象
【发布时间】:2013-06-17 10:38:58
【问题描述】:

我正在使用 WSDL 将 XML Soap 响应中的对象数组从我的 java 代码发送到我的项目中的 php。

我想为我的项目在 php 中存储值。

我尝试了很多方法,但无法找到如何解析我的 xml 和读取值。我不是在 xml 区域中导出的。

请任何人帮助我从价值观中读取我的价值观。

我的 SOAP 响应正文:

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" \xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:body>

<getactualtimerequestresponse xmlns="http://impl.sample.com">
        <getactualtimereturn>.
            <ns1:projectlist xmlns:ns1="http://response.sample.com">
                <item>
                    <ns2:userid xmlns:ns2="http://request.sample.com">4</ns2:userid>
                    <ns3:username xmlns:ns3="http://request.sample.com">Manoj Arun</ns3:username>
                </item>
                <item>
                    <ns5:userid xmlns:ns5="http://request.sample.com">5</ns5:userid>
                    <ns6:username xmlns:ns6="http://request.sample.com">Sethu Raman</ns6:username>
                </item>
            </ns1:projectlist>              
            <ns10:message xsi:nil="true" xmlns:ns10="http://response.sample.com"></ns10:message>
        </getactualtimereturn>
    </getactualtimerequestresponse>
</soapenv:body>
</soapenv:envelope>

projectList 是我在 java 中创建的对象。

在 PHP 中:

我试着像下面这样阅读,但我什么也没得到。

foreach($xml->xpath('//ns:projectList') as $header)
{
    foreach($header->item as $userIds)
    {
         echo $userIds->xpath('//ns:userId');
    }                       
}

提前谢谢...

【问题讨论】:

    标签: php xml-parsing wsdl nusoap


    【解决方案1】:
     $client = new SoapClient('http://url.com?wsdl');
     $params = array(Java arg => php value);
     $result = $client->Function( $parms );
     print_r($result);
    

    【讨论】:

      猜你喜欢
      • 2015-12-06
      • 2017-12-18
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-17
      • 2016-05-14
      • 1970-01-01
      相关资源
      最近更新 更多