xref: /PHP-5.5/ext/soap/tests/server028.phpt (revision 610c7fbe)
1--TEST--
2SOAP Server 28: SoapServer::setObject and __call()
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7class Foo {
8  function __call($name, $args) {
9    if ($name == "test") {
10      return "Hello World";
11    } else {
12      return SoapFault("Server","Function $name doesn't exist");
13    }
14  }
15}
16
17$foo = new Foo();
18$server = new SoapServer(null,array('uri'=>"http://testuri.org"));
19$server->setObject($foo);
20
21$HTTP_RAW_POST_DATA = <<<EOF
22<?xml version="1.0" encoding="ISO-8859-1"?>
23<SOAP-ENV:Envelope
24  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
25  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
26  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
27  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
28  xmlns:si="http://soapinterop.org/xsd">
29  <SOAP-ENV:Body>
30    <ns1:test xmlns:ns1="http://testuri.org" />
31  </SOAP-ENV:Body>
32</SOAP-ENV:Envelope>
33EOF;
34
35$server->handle($HTTP_RAW_POST_DATA);
36echo "ok\n";
37?>
38--EXPECT--
39<?xml version="1.0" encoding="UTF-8"?>
40<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" 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:testResponse><return xsi:type="xsd:string">Hello World</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
41ok
42