drgc9632 2014-07-09 11:35
浏览 29

带有nuSoap的complexType

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条回答 默认 最新

  • dstbp22002 2014-07-10 09:04
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法