php soap 中文,PHP-SOAP中的数据类型

PHP可以使用WSDL文件生成一组适当的方法,您可以将泛型对象、数组或标量作为参数传递给这些方法。还可以使用SoapClient类的第二个参数指定哪些类映射到哪些方法(classmap选项),以及哪些类型声明映射到哪些序列化回调函数(typemap选项)。在class doRequestMethod {

public $id;

public $attribute;

}

class theResponseClass {

/* ... */

}

$options = array(

'classmap' => array(

'doRequest' => 'doRequestMethod',

'theResponse' => 'theResponseClass'

/* ... */

),

'typemap' => array(

0 => array(

'type_ns' => 'http://example.com/schema/wsdl_type.xsd',

'type_name"' => 'wsdl_type',

'from_xml' => function ($xml_string) { /* ... */ },

'to_xml' => function ($soap_object) { /* ... */ }

)

/* ... */

)

)

$client = new SoapClient('/path/to/filename.wsdl', $options);

$request = new doRequestMethod();

$request->id = 0;

$request->attribute = "FooBar";

$result = $client->doRequest($request);

/*

* If 'dorequest' returns a 'theResponse' in the WSDL,

* then $result should of the type 'theResponseClass'.

*/

assert(get_class($result) === 'theResponseClass');

这需要大量的工作,所以我建议将SoapClient子类化以供您自己使用。此外,为了使代码更易于调试,请尽可能经常使用PHP类型提示函数和参数参数。它可以防止一整类错误,而且值得对性能造成较小的损失。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值