2016-11-10 15:07
浏览 66

使用所有XMLNS解析SOAP信封 - 不在Magento上工作

I have tried and tried and have been unable to come up with a solution. My issue is this: I have a SOAP envelop response which is as follows...

    <soapenv:envelope xmlns:soapenv="">
            <mcu:prescreenusereligibilityresponse xmlns:mcu="">
                <common:response xmlns:common="">

I then access the elements like this on my mac:

$xml=new SimpleXMLElement($string);
foreach($xml->getNamespaces(true) as $key=>$url){
    $xml->registerXPathNamespace($key, $url);


Using the same method on a separate Linux instance I get an error on the print_r line, saying the last child cannot be null. I have confirmed that the values are correct. I have also tried using $xml->xpath('//mcu:eligibilitystatuscode') with no success.

I'm really stuck -_-

图片转代码服务由CSDN问答提供 功能建议

我已经尝试过并且无法提出解决方案。 我的问题是: 我有一个SOAP信封响应,如下所示......

 &lt; soapenv:envelope xmlns:soapenv =“http://schemas.xmlsoap  .org / soap / envelope /“&gt; 
&lt; soapenv:header&gt; 
&lt; soapenv:body&gt; 
&lt; mcu:prescreenusereligibilityresponse xmlns:mcu =”  XOLTWS / MCUserEligibility / v1.0“&gt; 
&lt; common:response xmlns:common =”“&gt; 
&lt; common:  responsestatus&gt; 
&lt; common:code&gt; 1&lt; / common:code&gt; 
&lt; common:description&gt; Success&lt; / common:description&gt; 
&lt; / common:responsestatus&gt; 
&lt; / common:response&gt;  
&lt; mcu:eligibilitystatuscode&gt; 3&lt; / mcu:eligibilitystatuscode&gt; 
&lt; / mcu:prescreenusereligibilityresponse&gt; 
&lt; / soapenv:body&gt; 
&lt; / soapenv:header&gt; 
&lt; / soapenv:envelope&gt;  
 <  / code>  


  $ ns = array(); 
 $ xml  = new SimpleXMLElement($ string); 
foreach($ xml-&gt; getNamespaces(true)as $ key =&gt; $ url){
 $ xml-&gt; registerXPathNamespace($ key,$ url); 
 $ ns  [] = strval($网址); 
print_r(strval($ XML-&GT;儿童($ NS [0]) - &GT;报头 - &GT;身体 - &GT;儿童($ NS [1]  ) - &gt; prescreenusereligibilityresponse-&gt; eligibilitystatuscode)); 

在单独的Linux实例上使用相同的方法我在 print_r上出错了 line,表示最后一个子节点不能为null。 我已经确认这些值是正确的。 我也尝试使用 $ xml-&gt; xpath('// mcu:eligibilitystatuscode')但没有成功。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题