Zend Framework

There is no way to set custom user-agent to Zend_Soap_Client

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.2
  • Fix Version/s: 1.9.5
  • Component/s: Zend_Soap_Client
  • Labels:
    None

Description

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:

example
$opts = array('http' =>
    array(
        'user_agent' => 'custom'
    )
);
$context  = stream_context_create($opts);

$client = new SoapClient($wsdl, 
    array( 
        '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:

example
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);
        $client->setSoapClient($soapClient);
        return $client;
    }

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

Issue Links

Activity

Hide
Stefan Gehrig added a comment -

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

Show
Stefan Gehrig added a comment - Fixed in trunk (r18569) and in 1.9-release branch (r18570)

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
Not Specified
Original Estimate - Not Specified
Remaining:
0m
Remaining Estimate - 0 minutes
Logged:
30m
Time Spent - 30 minutes