<tfoot id='K7eGl'></tfoot>
    <legend id='K7eGl'><style id='K7eGl'><dir id='K7eGl'><q id='K7eGl'></q></dir></style></legend>

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

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

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

      肥皂:信封 SOAP-ENV:信封 PHP

      时间:2023-05-22

      <small id='0vNIi'></small><noframes id='0vNIi'>

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

                <tbody id='0vNIi'></tbody>

              1. 本文介绍了肥皂:信封 SOAP-ENV:信封 PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在尝试使用 PHP 的内置soap 函数登录API.我得到了这样的结果.

                I'm trying to login to an API using built-in soap functions of PHP. I got a result like this.

                [LoginResult]=> false,
                [ErrorMsg] => Login failed with the reason : The security object is invalid
                

                这是 API 提供者所要求的.

                This is what required by the API provider.

                <?xml version="1.0" encoding="utf-8"?>
                <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <soap:Body>
                    <Login xmlns="http://tempuri.org/Example/Service1">
                          <objSecurity>
                              <WebProviderLoginId>test</WebProviderLoginId>
                              <WebProviderPassword>test</WebProviderPassword>
                              <IsAgent>false</IsAgent>
                          </objSecurity>
                          <OutPut />
                          <ErrorMsg />
                    </Login>
                </soap:Body>
                </soap:Envelope>
                

                &,这是我能够使用函数生成的内容.

                &, here is what I was able to produce using functions.

                <?xml version="1.0" encoding="UTF-8"?>
                <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/Example/Service1">
                <SOAP-ENV:Body>
                    <ns1:Login>
                        <objSecurity>
                             <WebProviderLoginId>test</WebProviderLoginId>
                             <WebProviderPassword>test</WebProviderPassword>
                             <IsAgent>false</IsAgent>
                        </objSecurity>
                        <OutPut/>
                        <ErrorMsg/>
                    </ns1:Login>
                </SOAP-ENV:Body>
                </SOAP-ENV:Envelope>
                

                这是我用来发送请求的代码.

                Here is the code I used to send the request.

                <?php
                class objSecurity {
                function objSecurity($s, $i, $f)   {
                    $this->WebProviderLoginId = $s;
                    $this->WebProviderPassword = $i;
                    $this->IsAgent = $f;
                }
                }
                
                class nextObject {
                function nextObject($objSecurity)   {
                    $this->objSecurity=$pobjSecurity;
                    $this->OutPut=NULL;
                    $this->ErrorMsg=NULL;
                }
                }
                
                $url    = 'http://example.com/sampleapi/test.asmx?WSDL';
                $client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
                $struct = new objSecurity('test', 'test', false);
                $data   = new nextObject($struct);
                $soapstruct2 = new SoapVar($data, SOAP_ENC_OBJECT);
                print_r(
                   $client->__soapCall(
                       "Login",
                       array(new SoapParam($soapstruct2, "inputStruct"))
                   )
                );
                
                echo $client->__getLastRequest();
                
                ?>
                

                这些是我发现的不同之处.

                These are the differences I found.

                在我的请求中缺少 xmlns:xsi.

                要求以<soap:Envelope开头,但我的请求以<SOAP-ENV:Envelope开头.

                Requirement starts with <soap:Envelope, But my request starts with <SOAP-ENV:Envelope.

                我的请求中有一个额外的 xmlns:ns1.

                There is an extra xmlns:ns1 in my request.

                &函数名标签以ns1:开头.

                & The function name tag starts with ns1:.

                请帮助我将我的请求转换为所需的格式.

                Please help me to make my request into the required format.

                我不太了解 SOAP,我使用的是 PHP 5.3.13 版和 CakePHP 2.3.0.对不起,我的英语不好.

                I don't know much about the SOAP and I'm using PHP version 5.3.13 with CakePHP 2.3.0. Sorry, for my bad English.

                推荐答案

                这里是解决方案.:)

                <?php
                $url    = 'http://example.com/sampleapi/test.asmx?WSDL';
                $client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
                
                $user_param = array (
                  'WebProviderLoginId' => "test",
                  'WebProviderPassword' => "test",
                  'IsAgent' => false
                );
                
                $service_param = array (
                  'objSecurity' => $user_param,
                  "OutPut" => NULL,
                  "ErrorMsg" => NULL
                );
                
                print_r(
                   $client->__soapCall(
                       "Login",
                       array($service_param)
                   )
                );
                
                echo $client->__getLastRequest();
                
                ?>
                

                &请求是:

                <?xml version="1.0" encoding="UTF-8"?>
                <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/Example/Service1">
                <SOAP-ENV:Body>
                   <ns1:Login>
                       <ns1:objSecurity>
                           <ns1:WebProviderLoginId>test</ns1:WebProviderLoginId>
                           <ns1:WebProviderPassword>test</ns1:WebProviderPassword>
                           <ns1:IsAgent>false</ns1:IsAgent>
                       </ns1:objSecurity>
                   </ns1:Login>
                </SOAP-ENV:Body>
                </SOAP-ENV:Envelope>
                

                感谢这个链接.PHP SOAP 请求不正确

                这篇关于肥皂:信封 SOAP-ENV:信封 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:PHP Soap 非 WSDL 调用:如何传递参数? 下一篇:如何从此xml在php中生成soap请求?

                相关文章

                最新文章

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

              3. <tfoot id='blATw'></tfoot>
                  <bdo id='blATw'></bdo><ul id='blATw'></ul>

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

              4. <legend id='blATw'><style id='blATw'><dir id='blATw'><q id='blATw'></q></dir></style></legend>