繁体   English   中英

在PHP中读取简单的SOAP XML响应

[英]Reading a Simple SOAP XML response in PHP

我一直在寻找一个无法找到的切实可行的答案。

我也是SOAP的新手,但对PHP非常熟悉。

我用CURL发送我的SOAP请求,然后像这样返回响应:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetFeatureResponse xmlns="http://www.supportsite.com/webservices/">
  <GetFeatureResult>**string**</GetFeatureResult>
</GetFeatureResponse>
</soap:Body>
</soap:Envelope>

我需要在没有XML的MySQL数据库中保存-> GetFeatureResult'字符串'。 我尝试的所有内容都为空白。 这是我现在正在使用的:

$result = curl_exec($curl);
curl_close ($curl);

$resultXML = simplexml_load_string($result);


$item = $resultXML->GetFeatureResponse->GetFeatureResult;

PHP具有内置的soap客户端 这很容易。 只要将其指向正确的WSDL文件,它就会返回一个可供使用的PHP对象。

编辑:挖出一个我周围的例子...

  $sc = new SoapClient($wsdl, array(
    'location' => "https://$host:$port/path/",
    'login' => $user,
    'password' => $pass
  ));

  //$sc will now contain methods (maybe properties too) defined by the WSDL file
  //Getting the info you need could be as easy as
  $info = $sc->getInfo(array('parameter'=>'value'));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM