xref: /PHP-7.3/ext/soap/tests/server004.phpt (revision 9b661ea6)
1--TEST--
2SOAP Server 4: addfunctions
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7function Add($x,$y) {
8  return $x+$y;
9}
10function Sub($x,$y) {
11  return $x-$y;
12}
13
14$server = new soapserver(null,array('uri'=>"http://testuri.org"));
15$server->addfunction(array("Sub","Add"));
16
17$HTTP_RAW_POST_DATA = <<<EOF
18<?xml version="1.0" encoding="ISO-8859-1"?>
19<SOAP-ENV:Envelope
20  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
21  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
22  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
23  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24  xmlns:si="http://soapinterop.org/xsd">
25  <SOAP-ENV:Body>
26    <ns1:Add xmlns:ns1="http://testuri.org">
27      <x xsi:type="xsd:int">22</x>
28      <y xsi:type="xsd:int">33</y>
29    </ns1:Add>
30  </SOAP-ENV:Body>
31</SOAP-ENV:Envelope>
32EOF;
33
34$server->handle($HTTP_RAW_POST_DATA);
35echo "ok\n";
36?>
37--EXPECT--
38<?xml version="1.0" encoding="UTF-8"?>
39<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:AddResponse><return xsi:type="xsd:int">55</return></ns1:AddResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
40ok
41