ZF-8053: There is no way to set custom user-agent to Zend_Soap_Client

Issue Type: Bug Created: 2009-10-12T04:04:12.000+0000 Last Updated: 2009-11-19T00:51:57.000+0000 Status: Resolved Fix version(s): - 1.9.5 (27/Oct/09)

Reporter: Alexey Grunichev (alexey.grunichev) Assignee: Stefan Gehrig (sgehrig) Tags: - Zend_Soap_Client

Related issues: - ZF-6954



Method setOptions doesn't allow user_agent option. But this is only one possibility to customize user-agent. I don't know why it's not allowed. Probably one reason is to allow to user customize user-agent via stream_context, but it doesn't work:

<pre class="highlight">
$opts = array('http' =>
        'user_agent' => 'custom'
$context  = stream_context_create($opts);

$client = new SoapClient($wsdl, 
        'context_stream' => $context
        //'user_agent' => 'custom'

It's probably supposed to work, but it isn't. The only one way to customize user-agen - is to uncomment 'user_agent' option.

I've descovered only one way to do it without changes in ZF:

<pre class="highlight">
protected function _initTestSoapClient($wsdl) {
        $client = new Zend_Soap_Client($wsdl);
        $options = array_merge($client->getOptions(), array(
            'user_agent' => 'custom'
        $soapClient = new Zend_Soap_Client_Common(array($client, '_doRequest'), $wsdl, $options);
        return $client;

It doesn't seem good, so, I believe introducing new available option in setOptions is a reasonable idea.


Posted by Stefan Gehrig (sgehrig) on 2009-10-16T05:41:55.000+0000

Fixed in trunk (r18569) and in 1.9-release branch (r18570)

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.