Fatal error: Uncaught SoapFault exception: [ns1:Client.AUTH_1] Authentication Failed

前端 未结 2 1522
我寻月下人不归
我寻月下人不归 2021-01-22 13:12

In my wsdl file I have a user authentication block:



    
        

        
2条回答
  •  暖寄归人
    2021-01-22 14:03

    Without the full WSDL specification it's hard to tell where the issue is. But my guess is you're looking at the specs. wrong. Probably those are headers that need to be sent, not actual methods that need to be called.

    So try with something like this:

    // SOAP client options
    $options = array(
        'soap_version' => SOAP_1_2,
        'trace'        => true,
    );
    
    // initialise the SOAP client
    $apiURL = 'http://api.example.com/v2/example?wsdl';
    $namespace = 'http://api.example.com/v2/example?wsdl';
    
    $client = new SoapClient($apiURL, $options);
    
    // the SOAP headers
    $headers = array();
    
    $ua = array(
        'iId' => 123456,
        'sPassword' => 'fhfhfhfhfhfhfh46464dtdts64iyiyi', 
        'sType' => 'ghfh57477gghdkskdk68585jghhddhdghds',
    );
    
    $headers[] = new SoapHeader($namespace, 'UserAuthentication', $ua);
    
    // we could add multiple headers if needed
    
    $client->__setSoapHeaders($headers);
    
    // call the API function
    $response = $client->__soapCall("whateverYourTryingToCall", null);
    

提交回复
热议问题