示例#1
0
class TestHeader2 extends SoapHeader
{
    function __construct($data)
    {
        parent::__construct("http://testuri.org", "Test2", $data);
    }
}
function test()
{
    global $server;
    $server->addSoapHeader(new TestHeader1("Hello Header!"));
    $server->addSoapHeader(new TestHeader2("Hello Header!"));
    return "Hello Body!";
}
$server = new soapserver(null, array('uri' => "http://testuri.org"));
$server->addfunction("test");
$HTTP_RAW_POST_DATA = <<<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  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:si="http://soapinterop.org/xsd">
  <SOAP-ENV:Body>
    <ns1:test xmlns:ns1="http://testuri.org"/>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
EOF;
$server->handle($HTTP_RAW_POST_DATA);
echo "ok\n";
示例#2
0
<?php

function test1()
{
    throw new SoapFault("Server", "test1");
}
function test2()
{
    return new SoapFault("Server", "test2");
}
$server = new soapserver(null, array('uri' => "http://testuri.org"));
$server->addfunction(array("test1", "test2"));
$HTTP_RAW_POST_DATA = <<<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  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:si="http://soapinterop.org/xsd">
  <SOAP-ENV:Body>
    <ns1:test1 xmlns:ns1="http://testuri.org" />
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
EOF;
$server->handle($HTTP_RAW_POST_DATA);
$HTTP_RAW_POST_DATA = <<<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
示例#3
0
<?php

function Add($x, $y)
{
    return $x + $y;
}
$server = new soapserver(null, array('uri' => "http://testuri.org"));
$server->addfunction("Add");
$HTTP_RAW_POST_DATA = <<<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  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:si="http://soapinterop.org/xsd">
  <SOAP-ENV:Body>
    <ns1:Add xmlns:ns1="http://testuri.org">
      <x xsi:type="xsd:int">22</x>
      <y xsi:type="xsd:int">33</y>
    </ns1:Add>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
EOF;
$server->handle($HTTP_RAW_POST_DATA);
echo "ok\n";
示例#4
0
<?php

function Sum($a)
{
    $sum = 0;
    if (is_array($a)) {
        foreach ($a as $val) {
            $sum += $val;
        }
    }
    return $sum;
}
$server = new soapserver(null, array('uri' => "http://testuri.org"));
$server->addfunction("Sum");
$HTTP_RAW_POST_DATA = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Body xmlns:ns1="http://linuxsrv.home/~dmitry/soap/">
    <ns1:sum>
      <param0 SOAP-ENC:arrayType="xsd:int[2]" xsi:type="SOAP-ENC:Array">
        <val xsi:type="xsd:int">3</val>
        <val xsi:type="xsd:int">5</val>
      </param0>
    </ns1:sum>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
示例#5
0
<?php

function Add($x, $y)
{
    return $x + $y;
}
function Sub($x, $y)
{
    return $x - $y;
}
$server = new soapserver(null, array('uri' => "http://testuri.org"));
$server->addfunction(array("Sub", "Add"));
var_dump($server->getfunctions());
echo "ok\n";
示例#6
0
<?php

$server = new soapserver(null, array('uri' => "http://testuri.org"));
$server->addfunction(SOAP_FUNCTIONS_ALL);
$HTTP_RAW_POST_DATA = <<<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  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:si="http://soapinterop.org/xsd">
  <SOAP-ENV:Body>
    <ns1:strlen xmlns:ns1="http://testuri.org">
      <x xsi:type="xsd:string">Hello World</x>
    </ns1:strlen>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
EOF;
$server->handle($HTTP_RAW_POST_DATA);
echo "ok\n";