PHP5 Soap and HTTP Headers

Hi all,

i got an problem to call an Webservice thats need some HTTP-Headers
to work.

I try to call something like this:


$opts = array(
	'http'=>array(
	'header'=>
                      "X-AAC-ID: MYUSER\\r\
" .
	              "X-AAC-KEY: MYKEY\\r\
"
	)
	);

$ctx = stream_context_create($opts);
$client = new SoapClient(null,
	array(
        'stream_context'    => $ctx,
	'location'=>'http://serviceurl',
	'uri'=> 'serviceuri',
	'features'=> SOAP_SINGLE_ELEMENT_ARRAYS,
	'encoding' => 'utf-8',
	'trace' => true,
	'proxy_host' => "proxy",
	'proxy_port' => 8080,
	));

$params = array(
	new SoapParam('LOGIN:testuser','UserID'),
	new SoapParam('xxx','ASCID'),
	new SoapParam('SESSION','APIID')
	);

$result = $client->__soapCall("SessionCreateTrusted",$params);


i always get -> “No permission” because the missing http headers.

I also try to change

$opts = array(
	'http'=>array( [...]

to:

$opts = array(
	'ssl'=>array( [...]

or:

$opts = array(
	'https'=>array( [...]

always the same - the header looks like this:


REQUEST-Header:
POST http://myhost
Host: myhost
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.2.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://myhost/wsdl/1.1/SessionManagement_1.0#SessionCreateTrusted"
Content-Length: 654

none of the ACC-Headers is set.

Can anynow give me some advice ?

THX!

Seems like you didn’t look into the docs for SoapClient:

class SoapClient {
mixed__soapCall ( string $function_name, array $arguments [, array $options [, mixed $input_headers [, array &$output_headers]]] )
    }

Looks like you can specify input headers as fourth argument.

this headers are IN the Soap-Request (XML) like this:
<SOAP-ENV:Header>
[…]
</SOAP-ENV:Header>
<SOAP-ENV:Body>[…]

but i need the headers at the HTTP connection - so ist looks like:

REQUEST-Header:
POST http://myhost
Host: myhost
Connection: Keep-Alive
[b]X-AAC-ID: MYUSER
X-AAC-KEY: MYKEY[/b]
User-Agent: PHP-SOAP/5.2.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://myhost/wsdl/1.1/SessionManagement_1.0#SessionCreateTrusted"
Content-Length: 654


Oh, OK, sorry, my fault.
Perhaps you can override the SOAP-Class/method that actually sends the request.
I’m not that deep into SOAP, sorry that I can’t help you more.

Look for me like the PHP 5.2.1 Soap-Client
ignores the ‘stream_context’ Object.