我有这个WDSL
<xsd:element name="elementname">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" ref="miref"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>现在我必须通过nuSoap创建它,但是我找不到任何方法来省略complexType上的类型和名称,并在元素中设置complexType。
因此,如果我想创建一个元素,我使用以下代码:
$server->wsdl->AddElement(
array('name' => 'example1', 'type' => ''
)
); 如果我想创建另一个complexType:
$server->wsdl->addComplexType(
'example2',
'complexType',
'struct',
'all',
'',
array(
'id_user' => array('type' => '', 'maxOccurs' => '1', 'minOccurs' => '1'),
)
); 这就是我的问题: 1]我需要把那个complexType (example2)放在另一个元素(example1)中。2] complexType不应该在标记内有他的名字,但是函数addComplexType()和addElement(),如果我不给它们类型和名称,它们似乎就不起作用了。在文档中还典型地指出了它的需要:必须包括名称和类型的属性。
发布于 2014-07-10 17:04:20
我不熟悉nuSoap,但是因为它是基于原生PHP SoapServer的,所以我认为它很相似。
基本上,当使用PHP方法时,SoapServer将根据附加的XML Schema (XSD)解析返回的对象。
无论何时使用complexType,您都应该有相应的已定义的PHP类。StdClass也可以工作,但定义结构显然更好。
$response = new stdClass();
$response->sequenceElement = 'value';
return $response;显然,sequenceElement名称必须与您引用的XSD类相匹配(ref="miref")。
此外,如果向$response中添加额外的数据,SoapServer将忽略这些数据,因为它不是在XSD中定义的。
https://stackoverflow.com/questions/24652610
复制相似问题