简体   繁体   中英

Uncaught SoapFault exception: [HTTP] Proxy Authentication Required

Using the php Soapclient I got the exception:

Uncaught SoapFault exception: [HTTP] Proxy Authentication Required 

But when using a web browser with the same proxy set up, without specifying any credentials for that proxy, I can connect getting a XML response.

The system department ensures that there is no need for authenticate. Also I'm using the SoapUI just configuring the proxy for testing porpouses, without credentials again, and I can call the methods in the WS.

Why is the php SoapClient throwing that exception? Here is the code I'm using...

$this->client   = new SoapClient( null, array(
            'location'          => 'http://www.xxxxx.dev',
            'uri'               => self::URI,
            'proxy_host'        => self::PROXY_HOST, 
            'proxy_port'        => self::PROXY_PORT,
        ) );

Following solve the exception

$this->client = SoapClient( self::URL , array(  
    'proxy_host'        => self::PROXY_HOST,
    'proxy_port'        => self::PROXY_PORT,
    'authentication'    => SOAP_AUTHENTICATION_BASIC,
    'stream_context'    => stream_context_create(array(
    'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => false
        )
    ))
));

Misunderstood with the documentation, "URI of the WSDL file or NULL if working in non-WSDL mode" and I was expecting first parameter as a file, not an URL. In some of the attempts I already tried but forgetting to set up the stream context with the SSL parameter to skip peer verification. ( probably SOAP_AUTHENTICATION_BASIC isn't necessary )

Hope it helps someone

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM