2013-08-02 19:56
浏览 43

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

I have looked for a solid working answer on this can't find one.

I am also New at SOAP, but very familiar with PHP.

I send out my SOAP request with CURL and my response comes back like this:

<?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/">
<GetFeatureResponse xmlns="http://www.supportsite.com/webservices/">

I need to save the ->GetFeatureResult 'string' in a MySQL database without the XML. Everything I try returns blank. Here's what I'm using now:

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

$resultXML = simplexml_load_string($result);

$item = $resultXML->GetFeatureResponse->GetFeatureResult;
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douyu9012 2013-08-02 20:12

    PHP has a built in soap client. It is a LOT easier. As long as you point it to a proper WSDL file, it will return a PHP object ready to use.

    EDIT: Dug up an example I had around...

      $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'));
    解决 无用
    打赏 举报

相关推荐 更多相似问题