php中的soapUI WSDL Web服务获得500响应

时间:2018-08-08 04:08:08

标签: php ssl curl soap wsdl

enter image description here 我的代码:

<?php 

        $soapUrl = "https://example.com/server.php?wsdl"; 

        $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
                            soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mob="http://wigi.iseek.com.au/b2b/wigi/mobilevoice">
                           <soapenv:Header/>
                           <soapenv:Body>
                              <mob:GetPlans>
                                 <getPlansRequest>
                                    <accountID>555</accountID>
                                 </getPlansRequest>
                              </mob:GetPlans>
                              <soap:Fault>
                        </soap:Fault>
                           </soapenv:Body>
                        </soapenv:Envelope>'; 

           $headers = array(
                        "Content-type: text/xml;charset=\"utf-8\"",
                        "Accept: text/xml",
                        "Cache-Control: no-cache",
                        "Pragma: no-cache",
                        "SOAPAction: http://wigi.iseek.com.au/b2b/wigi/mobilevoice/GetPlans", 
                        "Content-length: ".strlen($xml_post_string),
                    ); //SOAPAction: your op URL

            $url = $soapUrl;
         $clientcert  = "/home/example/ssl/csrs/client.pem"; 
        $keyfile     =  "/home/example/ssl/keys/key.pem"; 
        $challenge    = "QAZXSW"; 
            // PHP cURL  for https connection with auth
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the

SOAP请求

          curl_setopt($ch, CURLOPT_SSLCERT, $clientcert); 
          curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $challenge); 
          curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM'); 
          curl_setopt($ch, CURLOPT_SSLKEY, $keyfile);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

        // converting
        $response = curl_exec($ch);
        $n=curl_getinfo($ch);
        print_r($n);
        curl_close($ch);

        // converting
        $response1 = str_replace("<soap:Body>","",$response);
        $response2 = str_replace("</soap:Body>","",$response1);

        // convertingc to XML
        $parser = simplexml_load_string($response2);
        // user $parser to get your data out of XML response and to display it.
?>

我的输出:

  

Array([url] => https://example.com.au/testservice/server.php?wsdl   [content_type] => text / xml; charset = utf-8 [http_code] => 500   [header_size] => 277 [request_size] => 743 [filetime] => -1   [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] =>   0.056019 [namelookup_time] => 0.004583 [connect_time] => 0.004818 [pretransfer_time] => 0.034581 [size_upload] => 484 [size_download] =>   278 [speed_download] => 4964 [speed_upload] => 8642   [download_content_length] => 278 [upload_content_length] => 484   [starttransfer_time] => 0.055833 [redirect_time] => 0 [redirect_url]   => [primary_ip] => 104.252.153.31 [certinfo] =>数组()[primary_port] => 443 [local_ip] => 104.252.153.31 [local_port] =>   34821)

我是saipui的新手,请帮忙

0 个答案:

没有答案