Hi Harlan, As I remember, in this time ext/soap's SoapServer doesn't provide a way to add soap headers (those were not received). You can workaround this limitation with some special kind of "SessionRequest" on first call. BTW please open a corresponding bug report on http://bugs.php.net (This is the best way to make things work) Thanks. Dmitry. > -----Original Message----- > From: Harlan Iverson [mailto:hjiverson@plauditdesign.com] > Sent: Saturday, March 11, 2006 2:20 AM > To: soap@lists.php.net > Subject: SoapServer can't return a header unless one is sent > > > Hello, > > I finally got soap headers to work (yay!), but I can't figure > out how to > send a header that I didn't receive, since receiving a header > seems to > be what invokes the magic function. > > For example, I had a sessionId header. The client makes its > first call > and doesn't not yet have a session initiated. I want the server to > always send a sessionId header, whether it received one or not. > > Here is a small reproduction. Comment/uncomment the soapenv:Header to > see what I am talking about: > > > ***** test.php ***** > > <?php > > ini_set("soap.wsdl_cache_enabled", 0); > > > $request = <<<REQUEST > <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <!-- > <soapenv:Header><ns1:sessionId > soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" > soapenv:mustUnderstand="0" xsi:type="soapenc:string" > xmlns:ns1="http://xml.apache.org/axis/session" > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">THIS > IS CLIENT > SESSION!</ns1:sessionId></soapenv:Header> > --> > > <soapenv:Body><ns2:getProduct > soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > xmlns:ns2="urn:com.plauditdesign.shoppingcart.client#"><productId > href="#id0"/></ns2:getProduct><multiRef id="id0" soapenc:root="0" > soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > xsi:type="xsd:int" > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">236< > /multiRef></soapenv:Body></soapenv:Envelope> > REQUEST; > > > > class CatalogFacade { > public function sessionId( $id ) { > echo "<!-- sessionId! $id -->"; > return "FROM SERVER: $id"; > } > > public function getProduct( $id ) { > return "PRODUCT $id"; > } > } > > > $server = new SoapServer( "CatalogFacade.wsdl" ); > $server->setClass( "CatalogFacade"); $server->handle( $request ); > > > ?> > > > > ***** CatalogFacade.wsdl ***** > > <?xml version="1.0" encoding="utf-8"?> > <definitions name="shoppingcart" > xmlns="http://schemas.xmlsoap.org/wsdl/" > xmlns:tns="urn:com.plauditdesign.shoppingcart.client#" > targetNamespace="urn:com.plauditdesign.shoppingcart.client#" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > > xmlns:axis-session="http://xml.apache.org/axis/session" > > xmlns:types="urn:com.plauditdesign.shoppingcart.client.types#"> > <!-- all datatypes will be imported to namespace types: --> > <types> > > > <schema xmlns="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://xml.apache.org/axis/session"> > <element name="sessionId" type="xs:string"/> > </schema> > > > </types> > > <!-- Obviously, the value for @location is wrong! > <import namespace="urn:com.plauditdesign.shoppingcart.client#" > location='http://www.example.org/schema/sample.xsd'/> > --> > > > <message name="sessionIdRequest"> > <part name="sessionId" > element="axis-session:sessionId"/> > </message> > <message name="sessionIdResponse"> > <part name="sessionId" > element="axis-session:sessionId"/> > </message> > > > <message name="getProduct-request"> > <part name="productId" type="xs:int"/> > </message> > <message name="getProduct-response"> > <part name="result" type="xs:string"/> > </message> > > <portType name="catalog-porttype"> > > <operation name="getProduct" parameterOrder="productId"> > <input name="getProduct-request" > message="tns:getProduct-request"/> > <output name="getProduct-response" > message="tns:getProduct-response"/> > </operation> > </portType> > > <!-- @type doesn't like tns: --> > <binding name="catalog-binding" type="tns:catalog-porttype"> > <!-- > <soap:binding style="document" > > transport="http://schemas.xmlsoap.org/soap/http"/> > --> > <soap:binding style="rpc" > > transport="http://schemas.xmlsoap.org/soap/http"/> > > > <operation name="getProduct"> > <soap:operation > soapAction="urn:com.plauditdesign.shoppingcart.client.CatalogF > acade#getProduct"/> > <input> > <soap:body use="encoded" > namespace="urn:com.plauditdesign.shoppingcart.client#" > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> > <soap:header > message="tns:sessionIdRequest" part="sessionId" > use="encoded" > encodingStyle="http://www.w3.org/2003/05/soap-encoding"/> > > </input> > <output> > <soap:body use="encoded" > namespace="urn:com.plauditdesign.shoppingcart.client#" > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> > <soap:header > message="tns:sessionIdResponse" part="sessionId" > use="encoded" > encodingStyle="http://www.w3.org/2003/05/soap-encoding"/> > > </output> > </operation> > > </binding> > > <service name="catalog"> > <!-- @binding doesn't like to be tns: --> > <port name="catalog-port" binding="tns:catalog-binding"> > <soap:address > location="http://admin.plauditdesign.com/zencart/webservice/so > ap-index.php?server=Catalog"/> > </port> > </service> > > </definitions> > > > Thanks! > Harlan > > -- > PHP Soap Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php