Adding own HTTP header fields along with a SOAP request in PHP

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I am new to PHP scripting and i am trying to connect to a soap server
(as mentioned below) using the SOAP extension comesup with PHP. Now my
requirement is to add my HTTP header fields along with my SOAP request,
so that the SOAP server will receive it and does some high level
processing. Is it possible to add our own HTTP header fields in PHP?
If i use the header() function to add the field into the HTTP header
and it neither reports an error nor adds it to the headers list.

Can anybody suggest me a solution for the problem I face?


header("X-Test: foo");
setcookie('foo', 'bar');
/* Define a custom response header */
header("X-Sample-Test: foo");

$client = new SoapClient(NULL,
        "location" => " ",
        "uri"      => "urn:calc",
        "style"    => SOAP_RPC,
        "use"      => SOAP_ENCODED,
        "trace"    => 1
echo ($client->__call(
            new SoapParam(
                10,"a"),new SoapParam(22,"b")
            "uri" => "urn:calc",
            "soapaction" => "add"
        )). "\n");
//echo $client->requestheaders();

Request received at Soap server:
Connection: Keep-Alive
User-Agent: PHP SOAP 0.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:calc"
Content-Length: 490
Cookie: Auth=Valid USER;

<?xml version="1.0" encoding="UTF-8"?>
xmlns:SOAP-ENV=" /"
xmlns:ns1="urn:calc" xmlns:xsd=" "
xmlns:xsi=" "
xmlns:SOAP-ENC=" /"
SOAP-ENV:encodingStyle=" /"><SOAP-ENV:Body><ns1:add><a
Quoted text here. Click to load it

Site Timeline