Edit report at https://bugs.php.net/bug.php?id=49853&edit=1

 ID:                 49853
 Comment by:         richard dot deguilhem at laposte dot net
 Reported by:        rumana024 at yahoo dot com
 Summary:            Soap Client stream context header option ignored
 Status:             Open
 Type:               Bug
 Package:            SOAP related
 Operating System:   Windows XP
 PHP Version:        5.2SVN-2009-10-12 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

I have the same problem with php 5.2.6 To 5.3.8.

[VERSION]

[CODE
class CMyClass extends SoapClient
{
 
    public function CMyClass($sWsdlUri = '',$aOptions = array())
    {
        $aOptions['stream_context'] = stream_context_create(array( 'http' => 
array('header'=>"foo: bar\r\n")));
 
        parent::__construct($sWsdlUri, $aOptions);
    }
 
    public function callSoapActionX()
    {
        $aParams = array(...);
        return $this->__soapCall('GetTokenSession', $aParams);
    }
}

[REQUEST HEADERS]
POST  HTTP/1.0
Host: 127.0.0.1:8052
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.8
Content-Type: application/soap+xml; charset=utf-8; action="GetTokenSession"
Content-Length: 532


Previous Comments:
------------------------------------------------------------------------
[2011-09-22 10:14:14] dave dot wilcock at gmail dot com

[VERSION]
PHP 5.3.2 (cli) (built: Apr 27 2010 20:28:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by 
eAccelerator

[CODE]
$str_auth_header = "Authorization: Bearer ". $str_token;
      
$arr_context = array('http' =>array('header' => $str_auth_header));

$obj_context = stream_context_create($arr_context);

$arr_options = array (
   'soap_version' => 'SOAP_1_2',
   'encoding' => 'UTF-8',
   'exceptions' => true,
   'trace' => true,
   'cache_wsdl' => 'WSDL_CACHE_NONE',
   'stream_context' => $obj_context
);

$this->obj_connection = new SoapClient(self::STR_BASE_URL, $arr_options);

[EXPECTED]
Authorization header in HTTP request

[GOT]
No Authorization header in HTTP request

[WORKAROUND/CODE]
ini_set('user_agent', 'PHP-SOAP/' . PHP_VERSION . "\r\n" . $str_auth_header);

[COMMENT]
No idea why appending the user agent string with the headers would work, but it 
seemingly does. Bizarre.

------------------------------------------------------------------------
[2011-05-09 17:09:04] vidalis dot aris at gmail dot com

Using php5.3.6 i couldn't pass extra HTTP headers to the SOAP request.
stream_context_create appears to get ignored

[VERSION]
PHP 5.3.6 with Suhosin-Patch (cli) (built: Apr 18 2011 11:14:25)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

[CODE]
$context = stream_context_create(array('http' => array('header' => "token: 
85E91AAC-7A4A-11E0-B46B-78E7D1E19752\r\n")));

        $soapparams = array(                    
                                                'stream_context' => $context,
                                                'trace' => 1,
                                                'exceptions' => 1,
                                                'soap_version' => SOAP_1_2,
                                                'encoding' => 'UTF-8',
                                                'features' => 
SOAP_SINGLE_ELEMENT_ARRAYS
                                );
$client = new SoapClient($wsdl,$soapparams);

[REQUEST HEADERS]
POST /SocialMetadataService HTTP/1.1
Host: test.host.com:9080
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.6
Content-Type: application/soap+xml; charset=utf-8; action="urn:getObjectID"
Content-Length: 331

------------------------------------------------------------------------
[2009-10-15 18:48:44] rumana024 at yahoo dot com

I have solved my issue... Yahoooooooooo...
I switched to php5.3. And I now the http headers are passing through.

------------------------------------------------------------------------
[2009-10-14 23:31:01] rumana024 at yahoo dot com

I see a conversation at 
http://aspn.activestate.com/ASPN/Mail/Message/php-dev/3710449 about 
Transfer-Encoding: chunked and its affect on stream_context parameters. Is this 
the problem?

------------------------------------------------------------------------
[2009-10-14 19:37:32] rumana024 at yahoo dot com

Is this a PHP bug? If not,can you please post some sample !working! code on 
creating a SOAP Client with the stream_context option and http header(in this 
case https). Those headers can be seen as the part of the http request headers. 
I have pretty much tried different suggestions that I read on diffrent threads 
on www and php.net to make a successful soap call.    

Regards
RI

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=49853


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=49853&edit=1

Reply via email to