Array response in WSDL - SOAP PHP

旧街凉风 提交于 2019-12-23 14:22:46

问题


In my wsdl code, i get an integer and i want to return result in array. Why in my input i have only one integer and i need result in array because in my php function i want to return information from Database from choosen integer by client.

Example, my client send 1, in my php i get information from "1" in DB as his "ID (int)","Name(string)","Number1(int)","Number2(int)","Date&Time of actual client demand « YYYY-MM-DD hh:mm:hh » (??)"

How i can do this ?

Thanks,

this is my actual wsdl with input of one integer and output of one integer :

<message name='getResultRequest'> 
  <part name='numeropark' type='xsd:int'/>
</message> 
<message name='getResultResponse'> 
  <part name='result' type='xsd:string'/> 
</message> 

<portType name='getResultPortType'> 
  <operation name='getResult'> 
    <input message='tns:getResultRequest'/> 
    <output message='tns:getResultResponse'/> 
  </operation> 
</portType> 

<binding name='getResultBinding' type='tns:getResultPortType'> 
  <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> 
  <operation name='getResult'> 
    <soap:operation soapAction='urn:xmethods-delayed-quotes#getResult'/> 
    <input> 
      <soap:body use='encoded' namespace='urn:xmethods-delayed-calcul' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
    </input> 
    <output> 
      <soap:body use='encoded' namespace='urn:xmethods-delayed-calcul' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
    </output> 
  </operation> 
</binding> 

<service name='getResultService'> 
  <port name='getResultPort' binding='getResultBinding'> 
    <soap:address location='http://XXX.XXXX.com/soap/soap-server.php'/> 
  </port> 
</service> 


回答1:


To return array, you should define a complexType. For example, if you want to return the array of strings, your WSDL should contain this part:

<wsdl:types>
    <xsd:schema targetNamespace="http://schema.example.com">
      <xsd:complexType name="resultArray">
        <xsd:complexContent>
          <xsd:restriction base="SOAP-ENC:Array">
            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]" />
          </xsd:restriction>
        </xsd:complexContent>
      </xsd:complexType>
    </xsd:schema>
</wsdl:types>
<message name='getResultRequest'> 
  <part name='numeropark' type='xsd:int'/>
</message> 
<message name='getResultResponse'> 
  <part name='result' type='tns:resultArray'/> 
</message>

And I suggest you use any WSDL generator to create description file.



来源:https://stackoverflow.com/questions/16045847/array-response-in-wsdl-soap-php

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