如何在PHP Curl或PHP Soapclient中进行XML请求?

问题描述 投票:0回答:1

我正在使用PHP进行XML请求。我们可以用PHP CURL或PHP SoapClient发出请求吗?以下是SOAP 1.2的示例:

POST /max/member.asmx HTTP/1.1
Host: api.relateddigital.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SendOngoingEMail xmlns="http://ws.euromsg.com/member">
      <ServiceTicket>string</ServiceTicket>
      <Key>string</Key>
      <Value>string</Value>
      <DemograficData>
        <EmKeyValue>
          <Key>string</Key>
          <Value>string</Value>
        </EmKeyValue>
        <EmKeyValue>
          <Key>string</Key>
          <Value>string</Value>
        </EmKeyValue>
      </DemograficData>
      <ForceUpdate>boolean</ForceUpdate>
      <OngoingCampaignId>string</OngoingCampaignId>
    </SendOngoingEMail>
  </soap12:Body>
</soap12:Envelope>
php curl soap soap-client php-curl
1个回答
0
投票

使用WSDL,您可以使用本机PHP SoapClient类。您必须传递PHP数组或结构良好的对象。

我强烈建议您使用WSDL到PHP生成器。这样,您将使用基于WSDL的适合的PHP SDK,以便使用完全OOP方法。此外,您不会想知道如何构造请求。最后,由于生成的类,响应处理将得到缓解。

试试PackageGenerator项目。

© www.soinside.com 2019 - 2024. All rights reserved.