SoapParam::SoapParam

(PHP 5, PHP 7)

SoapParam::SoapParamSoapParam コンストラクタ

説明

SoapParam::SoapParam ( mixed $data , string $name )

新規 SoapParam オブジェクトを生成します。

パラメータ

data

渡すもしくは返すデータ。 PHP の値としてこのパラメータを直接渡すことができますが、この場合、 paramN という名前が付けられますので SOAP サービスがこれを理解しないかも知れません。

name

パラメータの名前

例1 SoapParam::SoapParam() の例

<?php
$client 
= new SoapClient(null,array('location' => "http://localhost/soap.php",
                                    
'uri'      => "http://test-uri/"));
$client->SomeFunction(new SoapParam($a"a"),
                      new 
SoapParam($b"b"),
                      new 
SoapParam($c"c"));
?>

参考

add a note add a note

User Contributed Notes 6 notes

up
6
Alex
14 years ago
Make sure to always cast your parameters prior to creating a SoapParam.  Otherwise you will wind up with an incorrect xsi:type and possibly no value.

$value = 0;
$param0 = new SoapParam(
                $value, $param0_name);

will give you:

<$param0_name xsi:type="xsd:null"></$param0_name>

while:

$value = 0;
$param0 = new SoapParam(
                (int)$value, $param0_name);

<$param0_name xsi:type="xsd:int">0</$param0_name>

which is probably what you want.
up
6
lyroe_chan at hotmail dot com
10 years ago
If you want  to create a SOAP parameter like:

<a n="something">DATA</a>

You can try like this:

array('a' => array('_' => 'DATA', 'n'=>'something'));

This will generated xml like this:
<a n="something">DATA</a>
up
1
Alex
14 years ago
You probably want to try SoapVar instead of SoapParam if you want to specify attributes/namespace.
up
0
barryking93 at gmail dot com
16 years ago
You have to use SoapVar instead of SoapParam if you want it to do something fancy like using different opening and closing tags.  I ran into this using the SOAP API for Zimbra.
up
-9
Jeremy
17 years ago
Is there anyway to create a SOAP parameter like:

<a n="something">DATA</a>

If I try to form a param using the following code the resulting request is:

Code: SoapParam("DATA", "a n=\"something\"");
Result: <a n="something">DATA</a n="something">

This is giving me an error from the SOAP server because its expecting a properly formed closing tag without the encapsulated attribute.
up
-12
mjordan at sfu dot ca
10 years ago
You can also pass parameters (at least simple ones) to SOAP functions like this:

<?php
  $return
= $client->someFunction(array('paramName' => 'paramValue'));
?>
To Top