complexType with nuSoap

断了今生、忘了曾经 提交于 2019-12-13 05:04:02

问题


I have this WDSL

<xsd:element name="elementname">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="1" minOccurs="1" ref="miref"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

Now I have to create that via nuSoap but I can't find anyway to omit de type and name on the complexType and set the complexType inside of an element.

So if I want to create an element I use this code:

$server->wsdl->AddElement(  
        array('name' => 'example1', 'type' => ''
        )
); 

And if I want to create a complexType this other:

$server->wsdl->addComplexType(
    'example2',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'id_user' => array('type' => '', 'maxOccurs' => '1', 'minOccurs' => '1'),
    )
);   

So this are my problems: 1] I need to put that complexType (example2) inside of the other element (example1). 2] The complexType shouldn't have his name inside the tag but the functions addComplexType() and addElement(), dosn't seem to work if I don't give them the Type and the Name. Also in the documentation is typified that it's need: attributes that must include name and type.


回答1:


I'm not familiar with nuSoap, but as it's based on native PHP SoapServer, I'm asuming it's similar.

Basicly when working with PHP methods, SoapServer will parse returned objects according to attached XML Schema (XSD).

Whenever you're working with complexType you should have corresponding defined PHP class. StdClass will work too, but it's obviously better to define structure.

$response = new stdClass();
$response->sequenceElement = 'value';
return $response;

Obviously, sequenceElement name must match XSD class you're refering to (ref="miref").

Moreover, if you add additional data to your $response, it will be ignored by SoapServer, since it's not defined in XSD.



来源:https://stackoverflow.com/questions/24652610/complextype-with-nusoap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!