小编Nik*_*ola的帖子

在PHP SOAP中传递用户定义的类型

我无法理解如何在PHP SOAP调用中传递用户定义的类型.有人可以给我一个提示(或手册的链接)吗?

示例:在我的WSDL文件中,我定义了类型:

<types>
<schema targetNamespace="http://example.com/CustData"
        xmlns="http://www.w3.org/2000/10/XMLSchema">
  <element name="personalInformation">
    <complexType>
      <all>
        <element name="name" type="xsd:string"/>
        <element name="title" type="xsd:string"/>
        <element name="lang" type="xsd:string"/>
      </all>
    </complexType>
  </element>
</schema>
Run Code Online (Sandbox Code Playgroud)

我像这样定义服务响应消息:

<message name='getCustDataResponse'>
<part name='Result' type='xsd:personalInformation'/>
<part name='Result1' type='xsd:string'/>
</message>
Run Code Online (Sandbox Code Playgroud)

缺少的部分是 - 如何在SOAP服务器端初始化答案?

我试着写:

$arrRes['Result']['name'] = 'xxx';
$arrRes['Result']['title'] = 'yyy';
$arrRes['Result']['lang'] = 'zzz';
$arrRes['Result']['hehehehe1'] = 'test1';
$arrRes['Result']['hehehehe2'] = 'test2';
$arrRes['Result']['hehehehe3'] = 'test3';
$arrRes['Result']['hehehehe4'] = 'test4';
$arrRes['Result1'] = 'result1';
$arrRes['blablabla'] = 'hahaha';
return $arrRes;
Run Code Online (Sandbox Code Playgroud)

客户端获取响应,当我var_dump它时,它显示arrRes:

array(2) { ["Result"]=>  array(7) { ["name"]=>  string(3) "xxx" ["title"]=>  string(3) "yyy" ["lang"]=> …
Run Code Online (Sandbox Code Playgroud)

php soap types

5
推荐指数
1
解决办法
3799
查看次数

标签 统计

php ×1

soap ×1

types ×1