xref: /PHP-5.3/ext/soap/tests/server013.phpt (revision 9b661ea6)
1--TEST--
2SOAP Server 13: array handling
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7function Sum($a) {
8  $sum = 0;
9  if (is_array($a)) {
10    foreach($a as $val) {
11      $sum += $val;
12    }
13  }
14  return $sum;
15}
16
17$server = new soapserver(null,array('uri'=>"http://testuri.org"));
18$server->addfunction("Sum");
19
20$HTTP_RAW_POST_DATA = <<<EOF
21<?xml version="1.0" encoding="UTF-8"?>
22<SOAP-ENV:Envelope
23  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
24  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
25  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
26  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
27  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
28  <SOAP-ENV:Body xmlns:ns1="http://linuxsrv.home/~dmitry/soap/">
29    <ns1:sum>
30      <param0 SOAP-ENC:arrayType="xsd:int[2]" xsi:type="SOAP-ENC:Array">
31        <val xsi:type="xsd:int">3</val>
32        <val xsi:type="xsd:int">5</val>
33      </param0>
34    </ns1:sum>
35  </SOAP-ENV:Body>
36</SOAP-ENV:Envelope>
37EOF;
38$server->handle($HTTP_RAW_POST_DATA);
39echo "ok\n";
40?>
41--EXPECT--
42<?xml version="1.0" encoding="UTF-8"?>
43<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:sumResponse><return xsi:type="xsd:int">8</return></ns1:sumResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
44ok
45