我在从Fleetboard传递soap xml时遇到问题

时间:2018-12-21 09:19:59

标签: php api soap-client

这是我的代码

我对API开发了解不多,所以当我尝试运行此代码时我需要帮助

  

soapenv:Server会话未设置,或者可能无效。肥皂   客户必须使用URL重写来使用机载肥皂服务。   客户端6100000会话未设置,或者可能无效。肥皂   客户必须使用URL重写来使用机载肥皂服务。

$soapUrl = "https://www.fleetboard.com/soap_v1_1/services/PosService";
$xml_post_string = '<?xml version="1.0"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:data="http://www.fleetboard.com/data">
   <soapenv:Body>
      <data:login>
         <data:LoginRequest>
            <data:Fleetname>direct</data:Fleetname>
            <data:User>Online</data:User>
            <data:Password>Sovereign2019</data:Password>
         </data:LoginRequest>
      </data:login>
   </soapenv:Body>`
</soapenv:Envelope>';

 $header = array(
    "POST /soap_v1_1/services/BasicService",
    "Host: www.example.org",
    "Content-Type: application/soap+xml; charset=utf-8",
    "Content-Length: ".strlen($xml_post_string),
    );


    $soap_do = curl_init();
    curl_setopt($soap_do, CURLOPT_URL,            $soapUrl );
    curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt($soap_do, CURLOPT_POST,           true );
    curl_setopt($soap_do, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $xml_post_string);
    curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
    $result = curl_exec($soap_do);
    $airings = array();
   if($result === false) {
        $err = 'Curl error: ' . curl_error($soap_do);
        curl_close($soap_do);
        print $err;
    } else {
        curl_close($soap_do);
    }

    print_r($result);

        // /$xml = simplexml_load_string($result);

      // print_r($xml);

0 个答案:

没有答案