SOAP Headers with RPC encoding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am trying to implement a SOAP header based session ID that is
compatible with Apache Axis' SimpleSessionHandler (in other words, using HTTP headers isn't an option). I want to add a
soap:header to each operation in my binding; the specific issue is that
I can't figure out how to use SOAP headers with RPC encoding.

I've managed to hack together a small, but working, example of using
SOAP headers with literal encoding, which is derived from the tests in
the SOAP extension source (attached).

My attempts to convert it to RPC result in segmentation faults, and the
only examples of RPC encoding with headers I can find (namely T57.phpt)
use references, which I'm not sure how to change.

Thanks,
Harlan Iverson

-------------- test.php --------------
<?php

$HTTP_RAW_POST_DATA = <<<EOF
<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope";>
  <env:Header>
    <test:requiredHeader xmlns:test="http://example.org/ts-tests";
          env:mustUnderstand="true">foo</test:requiredHeader>
  </env:Header>
  <env:Body>
    <test:echoHeader xmlns:test="http://example.org/ts-tests";>
    </test:echoHeader>
  </env:Body>
</env:Envelope>
EOF;


class Soap12test {
	public $header;

	function requiredHeader($x) {
		$this->header = $x;
	}

	function echoHeader() {
	  return $this->header;
	}
	
	function echoOk($x) {
  	return $x;
	}
	
}

$server = new soapserver( "test.wsdl", array('soap_version'=>SOAP_1_2,'actor'=>"http://example.org/ts-tests/C";));
$server->setClass("Soap12test");

$server->handle();
echo "ok\n";

?>

-------------- test.wsdl --------------
<?xml version="1.0"?>

<definitions name="SOAP-12-TestDefinitions"
	targetNamespace="http://whitemesa.net/wsdl/soap12-test";
	xmlns="http://schemas.xmlsoap.org/wsdl/";
	xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/";
	xmlns:xsd="http://www.w3.org/2001/XMLSchema";
	xmlns:enc="http://www.w3.org/2003/05/soap-encoding";
	xmlns:tns="http://whitemesa.net/wsdl/soap12-test";
	xmlns:types="http://example.org/ts-tests/xsd";
	xmlns:test="http://example.org/ts-tests";
	xmlns:xlink="http://www.w3.org/1999/xlink";
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
	xmlns:enc11="http://schemas.xmlsoap.org/soap/encoding/";>
	<types>


    	<schema xmlns="http://www.w3.org/2001/XMLSchema";
			elementFormDefault="qualified"
			targetNamespace="http://example.org/ts-tests";>


			<!-- unknown header block type -->
			<complexType name="UnknownType">
					<sequence>
<element minOccurs="0" maxOccurs="1" name="stringValue" type="xsd:string" />
					</sequence>
			</complexType>

			<!-- 3.2.1 echoOk -->
			<element name="echoOk" type="xsd:string"/>

			<!-- 3.2.2 responseOk -->
			<element name="responseOk" type="xsd:string"/>

			<!-- 3.2.4 requiredHeader -->
			<element name="requiredHeader" type="xsd:string"/>

			<element name="echoHeader" type="xsd:string"/>
			<element name="echoHeaderResponse" type="xsd:string"/>
			
			<element name="Unknown" type="types:UnknownType" />

		</schema>

	</types>

	<!-- echoOk body/header block -->
	<message name="echoOkRequest">
		<part name="echoOk" element="test:echoOk"/>
	</message>
	<message name="echoOkResponse">
		<part name="responseOk" element="test:responseOk"/>
	</message>

	<message name="requiredHeaderRequest">
		<part name="requiredHeader" element="test:requiredHeader"/>
	</message>
	<message name="echoHeaderRequest">
		<part name="responseHeader" element="test:echoHeader"/>
	</message>
	<message name="echoHeaderResponse">
		<part name="responseHeader" element="test:echoHeaderResponse"/>
	</message>

	<!-- "unknown" header block -->
	<message name="UnknownHdrBlockLit">
		<part name="Unknown" element="test:Unknown" />
	</message>
	<message name="UnknownHdrBlockEnc">
		<part name="Unknown" type="types:UnknownType" />
	</message>

  	<portType name="Soap12TestPortTypeDoc">

    		<operation name="requiredHeader">
      			<input message="tns:requiredHeaderRequest" />
    		</operation>
    		<operation name="echoHeader">
      			<input message="tns:echoHeaderRequest" />
      			<output message="tns:echoHeaderResponse" />
    		</operation>
	</portType>

  	<binding name="Soap12TestDocBinding" type="tns:Soap12TestPortTypeDoc">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"; />

    		<operation name="requiredHeader">
      			<soap12:operation/>
      			<input>
        			<soap12:body use="literal" />
      			</input>
    		</operation>
    		<operation name="echoHeader">
      			<soap12:operation/>
      			<input>
        			<soap12:body use="literal" />
<soap12:header message="tns:echoOkRequest" part="echoOk" use="literal" /> <soap12:header message="tns:UnknownHdrBlockLit" part="Unknown" use="literal" />
      			</input>
      			<output>
        			<soap12:body use="literal" />
<soap12:header message="tns:echoOkResponse" part="responseOk" use="literal" />
      			</output>
    		</operation>
	</binding>


	<service name="WhiteMesaSoap12TestSvc">
  		<port name="Soap12TestDocPort" binding="tns:Soap12TestDocBinding">
    			<soap12:address location="http://localhost/soap12/test-doc"/>
  		</port>

	</service>

</definitions>

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux