<bdo id='nv0XV'></bdo><ul id='nv0XV'></ul>

    <i id='nv0XV'><tr id='nv0XV'><dt id='nv0XV'><q id='nv0XV'><span id='nv0XV'><b id='nv0XV'><form id='nv0XV'><ins id='nv0XV'></ins><ul id='nv0XV'></ul><sub id='nv0XV'></sub></form><legend id='nv0XV'></legend><bdo id='nv0XV'><pre id='nv0XV'><center id='nv0XV'></center></pre></bdo></b><th id='nv0XV'></th></span></q></dt></tr></i><div id='nv0XV'><tfoot id='nv0XV'></tfoot><dl id='nv0XV'><fieldset id='nv0XV'></fieldset></dl></div>
  1. <tfoot id='nv0XV'></tfoot><legend id='nv0XV'><style id='nv0XV'><dir id='nv0XV'><q id='nv0XV'></q></dir></style></legend>

      <small id='nv0XV'></small><noframes id='nv0XV'>

      使用 cURL 执行 SOAP

      时间:2023-05-22

      <legend id='Pdx6r'><style id='Pdx6r'><dir id='Pdx6r'><q id='Pdx6r'></q></dir></style></legend>
          <bdo id='Pdx6r'></bdo><ul id='Pdx6r'></ul>

              <tbody id='Pdx6r'></tbody>
          • <tfoot id='Pdx6r'></tfoot>

            <small id='Pdx6r'></small><noframes id='Pdx6r'>

              1. <i id='Pdx6r'><tr id='Pdx6r'><dt id='Pdx6r'><q id='Pdx6r'><span id='Pdx6r'><b id='Pdx6r'><form id='Pdx6r'><ins id='Pdx6r'></ins><ul id='Pdx6r'></ul><sub id='Pdx6r'></sub></form><legend id='Pdx6r'></legend><bdo id='Pdx6r'><pre id='Pdx6r'><center id='Pdx6r'></center></pre></bdo></b><th id='Pdx6r'></th></span></q></dt></tr></i><div id='Pdx6r'><tfoot id='Pdx6r'></tfoot><dl id='Pdx6r'><fieldset id='Pdx6r'></fieldset></dl></div>
                本文介绍了使用 cURL 执行 SOAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在尝试使用 cURL 执行 SOAP 函数(因为我在使用 SoapClient() 时遇到错误).

                I am trying to execute an SOAP-function using cURL (because I get an error using the SoapClient().

                这是我的代码(已完成一半)

                This is my code (that is halfway working)

                $credentials = "username:pass"; 
                $url = "https://url/folder/sample.wsdl"; 
                $page = "/folder"; 
                $headers = array( 
                    "POST ".$page." HTTP/1.0", 
                    "Content-type: text/xml;charset="utf-8"", 
                    "Accept: text/xml", 
                    "Cache-Control: no-cache", 
                    "Pragma: no-cache", 
                    "SOAPAction: "customerSearch"", 
                    "Authorization: Basic " . base64_encode($credentials) 
                ); 
                
                $ch = curl_init(); 
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_URL,$url); 
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
                curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
                curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']); 
                $data = curl_exec($ch); 
                

                问题在于没有执行 SOAP 操作.而且我还需要将参数传递给操作.这甚至可能吗?

                The problem is that the SOAP-action is not being performed. And I also need to pass arguments to the action. Is this even possible?

                推荐答案

                您需要指定 POST 的 cURL 选项,并设置请求的正文 - 如果您不发送正文,则 POST 请求没有意义(更重要的是,它不是 SOAP).构建一个完整的 HTTP 请求标头不会削减它.

                You need to specify the cURL options to POST, and set the body of the request - if your not sending a body, there's no point in a POST request (and more importantly, it isn't SOAP). Building a complete HTTP request header just won't cut it.

                $credentials = "username:pass"; 
                $url = "https://url/folder/sample.wsdl";
                $body = ''; /// Your SOAP XML needs to be in this variable
                
                $headers = array( 
                    'Content-Type: text/xml; charset="utf-8"', 
                    'Content-Length: '.strlen($body), 
                    'Accept: text/xml', 
                    'Cache-Control: no-cache', 
                    'Pragma: no-cache', 
                    'SOAPAction: "customerSearch"'
                ); 
                
                $ch = curl_init(); 
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_URL, $url); 
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
                curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']);
                
                // Stuff I have added
                curl_setopt($ch, CURLOPT_POST, true); 
                curl_setopt($ch, CURLOPT_POSTFIELDS, $body); 
                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                curl_setopt($ch, CURLOPT_USERPWD, $credentials);
                
                $data = curl_exec($ch); 
                

                这篇关于使用 cURL 执行 SOAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 PHP 进行 SOAP 身份验证 下一篇:PHP SoapClient 和复杂的标头

                相关文章

                最新文章

                1. <small id='0DDVo'></small><noframes id='0DDVo'>

                  <tfoot id='0DDVo'></tfoot>
                  • <bdo id='0DDVo'></bdo><ul id='0DDVo'></ul>
                  <legend id='0DDVo'><style id='0DDVo'><dir id='0DDVo'><q id='0DDVo'></q></dir></style></legend>
                2. <i id='0DDVo'><tr id='0DDVo'><dt id='0DDVo'><q id='0DDVo'><span id='0DDVo'><b id='0DDVo'><form id='0DDVo'><ins id='0DDVo'></ins><ul id='0DDVo'></ul><sub id='0DDVo'></sub></form><legend id='0DDVo'></legend><bdo id='0DDVo'><pre id='0DDVo'><center id='0DDVo'></center></pre></bdo></b><th id='0DDVo'></th></span></q></dt></tr></i><div id='0DDVo'><tfoot id='0DDVo'></tfoot><dl id='0DDVo'><fieldset id='0DDVo'></fieldset></dl></div>