By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

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

P: n/a
Hi,

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?

Thanks,
Ramas

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

$client = new SoapClient(NULL,
array(
"location" => "http://127.0.0.7:3490",
"uri" => "urn:calc",
"style" => SOAP_RPC,
"use" => SOAP_ENCODED,
"trace" => 1
));
$client->__setCookie("Auth",$tem);
echo ($client->__call(
"add",
array(
new SoapParam(
10,"a"),new SoapParam(22,"b")
),
array(
"uri" => "urn:calc",
"soapaction" => "add"
)). "\n");
//echo $client->requestheaders();
var_dump(headers_list());
?>


Request received at Soap server:
==================================
POST HTTP/1.1
Host: 127.0.0.7:3490
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"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:calc" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:add><a
xsi:type="xsd:int">10</a><b
xsi:type="xsd:int">22</b></ns1:add></SOAP-ENV:Body></SOAP-ENV:Envelope>


Sep 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.