Home » Php » PHP soapserver() use header value

PHP soapserver() use header value

Posted by: admin August 11, 2018 Leave a comment

Questions:

i need your help for soap server web service.
i need to use for authentification and other information and for main working.
But i don’t find how use value of WSDL Header.

How i can use , , value on Myclass ?
It’s work with value of
I don’t know where is my mistake and i don’t many topics or example for help me.

result wsdl

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header>
      <test1>I don't know how use this data</test1>
      <test2>I don't know how use this data</test2>
      <test3>I don't know how use this data</test3>
   </soapenv:Header>
   <soapenv:Body>
      <RequestData>I can use this Data</RequestData>
   </soapenv:Body>
</soapenv:Envelope>

request.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<definitions
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  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/"
  xmlns:tns="http://myserver/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns="http://schemas.xmlsoap.org/wsdl/"
  targetNamespace="http://myserver/">

<types>
  <schema targetNamespace="http://myserver/"
           xmlns="http://www.w3.org/2001/XMLSchema"
           xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <element name="keyElem" type="xsd:base64Binary"/>
  </schema>
</types>

<message name="BodyRequest">
  <part name="RequestData" type="xsd:string" />
</message>
<message name="BodyResponse">
  <part name="PDFResponse" type="xsd:string" />
</message>
<message name="HeaderAuthen">
  <part name="test1" type="xsd:string" />
  <part name="test2" type="xsd:string" />
  <part name="test3" type="xsd:string" />
</message>

<portType name="BatchPortType">
  <operation name="MyFunction">
    <input message="tns:BodyRequest"/>
    <output message="tns:BodyResponse"/>
  </operation>
</portType>

<binding name="BatchBinding" type="tns:BatchPortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="MyFunction">
      <soap:operation soapAction="http://myserver/server.php" style="document"/>
      <input>
        <soap:body use="literal"/>
        <soap:header message="tns:HeaderAuthen" part="test3"/>
        <soap:header message="tns:HeaderAuthen" part="test2"/>
        <soap:header message="tns:HeaderAuthen" part="test1"/>
      </input>
      <output>
        <soap:body use="literal"/>
        <soap:header message="tns:HeaderAuthen" part="test3"/>
        <soap:header message="tns:HeaderAuthen" part="test2"/>
        <soap:header message="tns:HeaderAuthen" part="test1"/>
      </output>
  </operation>
</binding>

<service name="Batch">
        <port name="BatchPort" binding="tns:BatchBinding">
            <soap:address location="http://myserver/server.php"/>
        </port>
    </service>

</definitions>

serveur.php

<?php

    class MyClass{

    function MyFunction($test){

        if($test == "data")
        {
            return "OK : ".$test;
        }
        else
        {
            return "KO : ".$test;
        }
    }


}

$serversoap=new SoapServer("http://myserver/request.wsdl");
$serversoap->setClass("MyClass");
$serversoap->handle();
?>

Can you help me ?

Many thanks

Answers: