php curl post请求soap webservice接口

 

直接上代码了。

SOAP 1.1

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /AirLogisticsAPP/AirLogisticsService.asmx HTTP/1.1
Host: 58.213.128.130
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://58.213.128.130/HelloWorld"



  
    
  

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length



  
    
      string
    
  
    /**
     * 使用curl发送post请求
     * @param $url
     * @param string $data
     * @return bool|mixed
     */
    public function sendCurlPost($url, $header = '', $post){
        //初始化,创建一个cURL资源
        $ch = curl_init();
        //设置cURL选项
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, "user-agent:Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0");
        curl_setopt($ch, CURLOPT_HEADER, 0);    //是否返回文件头信息
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    //不直接打印输出
        curl_setopt($ch, CURLOPT_POST, 1);  //是否post请求
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //post传输数据
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        //执行cURL会话
        $response = curl_exec($ch);
        file_put_contents("log11ss.txt", $response);

        if (!curl_errno($ch)){
            $result =  $response;
        }else{
        //    echo 'Curl error: ' . curl_error($ch);
            $result = false;
        }
     
        //关闭cURL释放资源
        curl_close($ch);
     
        return $result;
    }
     
    public function ceshiweb()
    {
        $url = "http://58.213.128.130:888/AirLogisticsAPP/AirLogisticsService.asmx";
        $header[] = "Content-type: text/xml";

        $post = "
                
                  
                    
                      xxx
                      xxx
                      xxxxxx
                    
                  
                  
                    
                      618609556xx
                      IO
                    
                  
                ";

        $res = $this->sendCurlPost($url,$header,$post);
        print_r($res);die;
    }

 

你可能感兴趣的:(php,杂记)