假如我要调用
https://api.securefreedom.com/nuriche/Webservice/OnlineAPI.asmx?op=CheckEmail
用户名与密码为xxx.
我看了看,这个api的request的格式为POST /nuriche/Webservice/OnlineAPI.asmx HTTP/1.1
Host: api.securefreedom.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>
    <CheckEmail xmlns="http://www.securefreedom.com/">
      <Credentials>
        <Username>string</Username>
        <Password>string</Password>
      </Credentials>
      <Email>string</Email>
      <Type>int</Type>
      <ExcludeRepNumber>string</ExcludeRepNumber>
      <ExcludeCustomerNumber>string</ExcludeCustomerNumber>
    </CheckEmail>
  </soap12:Body>
</soap12:Envelope>求如何发送$ch = curl_init ();

curl_setopt ( $ch, CURLOPT_URL, "https://api.securefreedom.com/nuriche/Webservice/OnlineAPI.asmx?op=CheckEmail" );
curl_setopt ( $ch, CURLOPT_HEADER, false );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, true );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt(  $ch, CURLOPT_POSTFIELDS, 这个地方需要拼数据?);

curl_setopt ( $ch, CURLOPT_HTTPHEADER, 如何放验证信息)//
$response = curl_exec ( $ch ); 
curl_close ( $ch );
echo $response;

解决方案 »

  1.   

    php有现成的SOAP扩展<?php$client = new SoapClient("some.wsdl");
    $client->SomeFunction($a, $b, $c);$client->__soapCall("SomeFunction", array($a, $b, $c));
    $client->__soapCall("SomeFunction", array($a, $b, $c), NULL,
                        new SoapHeader(), $output_headers);
    $client = new SoapClient(null, array('location' => "http://localhost/soap.php",
                                         'uri'      => "http://test-uri/"));
    $client->SomeFunction($a, $b, $c);
    $client->__soapCall("SomeFunction", array($a, $b, $c));
    $client->__soapCall("SomeFunction", array($a, $b, $c),
                        array('soapaction' => 'some_action',
                              'uri'        => 'some_uri'));
    ?>