简体   繁体   English

如何将 SOAP XML 请求转换为 PHP?

[英]How to translate a SOAP XML Request to PHP?

I need to send the soap request with PHP.我需要使用 PHP 发送 soap 请求。

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.datacontract.org/2004/07/Common" xmlns:ns2="http://tempuri.org/">
  <SOAP-ENV:Body>
    <ns2:SaveThePayment>
      <ns2:reglement>
        <ns1:CENTRE>330</ns1:CENTRE>
        <ns1:CLIENT>00800808782</ns1:CLIENT>
        <ns1:EXIGIBILITE>25/03/19</ns1:EXIGIBILITE>
        <ns1:MONTANT>1000</ns1:MONTANT>
        <ns1:NUMFACTURE>787322</ns1:NUMFACTURE>
        <ns1:ORDRE>01</ns1:ORDRE>
        <ns1:PERIODE>201902</ns1:PERIODE>
      </ns2:reglement>
      <ns2:plateforme>?</ns2:plateforme>
    </ns2:SaveThePayment>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is how I did in PHP这是我在 PHP 中所做的

class MakeIt
{
    protected $url = "https://server_ip:port?wsdl";

    public function makeItHere()
    {
        $reglement = new ReferenceReglement();
        $reglement->CENTRE = "330";
        $reglement->CLIENT = "00800808782";
        $reglement->EXIGIBILITE = "25/03/19";
        $reglement->MONTANT = 3000.00;
        $reglement->NUMFACTURE = "787322";
        $reglement->ORDRE = "01";
        $reglement->PERIODE = "201902";

        $clientSoap = new SoapClient($this->url);
        // dd($clientSoap->__getTypes());
        $response = $clientSoap->__soapCall("SaveThePayment", [
            "reglement" => $reglement,
            // "plateforme" => ""
        ]);

        dd($response);
    }
}

class ReferenceReglement
{
    public $CENTRE;
    public $CLIENT;
    public $ORDRE;
    public $NUMFACTURE;
    public $PERIODE;
    public $MONTANT;
    public $EXIGIBILITE;
}

Here is the error I get这是我得到的错误

SoapFault The server could not process the request due to an internal error. SoapFault 由于内部错误,服务器无法处理请求。 For more information about the error, enable IncludeExceptionDetailInFaults (from ServiceBehaviorAttribute or from the configuration behavior ) on the server to return the exception information to the client, or enable tracking according to the Microsoft .NET Framework Software Development Kit (SDK) documentation and review the server's tracking logs.有关错误的更多信息,请在服务器上启用 IncludeExceptionDetailInFaults(来自 ServiceBehaviorAttribute 或来自配置行为)以将异常信息返回给客户端,或者根据 Microsoft .NET 框架软件开发工具包 (SDK) 文档启用跟踪并查看服务器的跟踪日志。

First step would be to look at the logs in your soap client server.第一步是查看 soap 客户端服务器中的日志。

Here the issue might be the argument type that you are passing for "reglement" which is an object.这里的问题可能是您为“reglement”传递的参数类型,即 object。 So check in the soap server if the argument type is same or not.因此,如果参数类型相同,请检查 soap 服务器。

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

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