soap:Envelope SOAP-ENV:Envelope PHP

后端 未结 1 834
名媛妹妹
名媛妹妹 2020-12-17 18:59

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 t         


        
相关标签:
1条回答
  • 2020-12-17 19:41

    Here is the solution. :)

    <?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();
    
    ?>
    

    & the request was:

    <?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>
    

    Thanks to this link. PHP SOAP Request not right

    0 讨论(0)
提交回复
热议问题