通过soapclient发布请求

时间:2018-12-22 16:33:15

标签: php xml soap

当前,我正在通过CURL与Soap Server通信。我正在使用特定的标头将XML数据发送到URL,我想用SoapClient类代替curl,但是不确定如何做。

卷曲代码:

$ch = curl_init($url);                                                                      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);                                                                    
                                                                                                                $xml = curl_exec($ch); 
curl_close($ch);

参数:

标题:

Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SoapAction: "http://www.mygemini.com/schemas/mygemini/GetAccountMovements"
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

身体:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myg="http://www.mygemini.com/schemas/mygemini" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
  <soapenv:Header>
  <wsse:Security>
    <wsse:UsernameToken>
      <wsse:Username>USER</wsse:Username>
      <wsse:Password>PASSWORD</wsse:Password>
      <wsse:Nonce>1111</wsse:Nonce>
    </wsse:UsernameToken>
  </wsse:Security>
  </soapenv:Header>
  <soapenv:Body>
    <myg:GetAccountMovementsRequestIo>
      <myg:accountMovementFilterIo>
        <myg:periodFrom>2015-01-01T00:00:00.000</myg:periodFrom>
      </myg:accountMovementFilterIo>
    </myg:GetAccountMovementsRequestIo>
  </soapenv:Body>
</soapenv:Envelope>

0 个答案:

没有答案