如何在PHP中使用cURL发出SOAP请求(Drupal)

时间:2019-03-04 13:42:08

标签: php xml web-services soap

我一直在尝试让SOAP请求在Drupal 7的自定义模块中工作。我正在使用cURL在函数中发出请求。现在,无论何时激活该功能,我正在使用的页面都会在现场维护中告诉我们。下面是功能的摘录。我的问题是如何获取SOAP响应提供的电子邮件的值并将其放在PHP变量中?以下是我使用SimpleXML的选项。

$xml = simplexml_load_string($response);
$namespace = 'http://exacttarget.com/wsdl/partnerAPI';
$soap = $xml->children($namespace);
$subscriber_email = $soap->Body->RetrieveResponseMsg->Results->Properties->Property[2]->Value;

这是我尝试解析的SOAP UI自身对SOAP请求的结果:


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <soap:Header>
      <wsa:Action>RetrieveResponse</wsa:Action>
      <wsa:MessageID>[REMOVED]</wsa:MessageID>
      <wsa:RelatesTo>[REMOVED]</wsa:RelatesTo>
      <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
      <wsse:Security>
         <wsu:Timestamp wsu:Id="Timestamp-715a4a7e-4657-48c7-8b01-612580d331ce">
            <wsu:Created>2019-03-04T12:41:08Z</wsu:Created>
            <wsu:Expires>2019-03-04T12:46:08Z</wsu:Expires>
         </wsu:Timestamp>
      </wsse:Security>
   </soap:Header>
   <soap:Body>
      <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <OverallStatus>OK</OverallStatus>
         <RequestID>[REMOVED]</RequestID>
         <Results xsi:type="DataExtensionObject">
            <PartnerKey xsi:nil="true"/>
            <ObjectID xsi:nil="true"/>
            <Type>DataExtensionObject</Type>
            <Properties>
               <Property>
                  <Name>SubscriberID</Name>
                  <Value>[REMOVED]</Value>
               </Property>
               <Property>
                  <Name>FirstName</Name>
                  <Value>[REMOVED]</Value>
               </Property>
               <Property>
                  <Name>Email</Name>
                  <Value>[REMOVED]</Value>
               </Property>
            </Properties>
         </Results>
      </RetrieveResponseMsg>
   </soap:Body>
</soap:Envelope>

0 个答案:

没有答案