PHP SoapClient __getFunctions() returning UNKNOWN types

◇◆丶佛笑我妖孽 提交于 2020-01-04 06:15:40

问题


I am trying to build a sample wsdl file that will be read by the PHP SoapClient, and although my wsdl document sort-of works (it returns the function correctly), something is still not right because PHP's __getFunctions method returns the following:

array(1) { [0]=> string(35) "UNKNOWN getDocument(UNKNOWN $input)" } 

From what is returned by this function it seems that the type definitions are not 100% correct as the types are showing as UNKNOWN.

<?xml version="1.0"?>
<definitions name="Document" targetNamespace="urn:Document" xmlns:tns="urn:Document"     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> 
<types>
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Document">
    <xsd:element name="InputUserType" type="xsd:string" />
    <xsd:element name="DocumentResponseType" type="xsd:string" />         
    </xsd:schema>           
</types>

<message name="getDocumentInputUser">
    <part name="input" type="tns:InputUserType" />
</message> 

<message name="getDocumentResponse">
    <part name="return" type="tns:DocumentResponseType" />
</message>  

<portType name="DocumentPort">
    <operation name="getDocument">
        <input message="tns:getDocumentInputUser" />
        <output message="tns:getDocumentResponse" />
    </operation>
</portType>

<binding name="DocumentBinding" type="tns:DocumentPort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="getDocument">
        <soap:operation soapAction="urn:DocumentAction" />
        <input>
            <soap:body use="encoded" namespace="urn:Document" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </input>
        <output>
            <soap:body use="encoded" namespace="urn:Document" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </output>
    </operation>      
</binding>

<service name="DocumentService">
    <port name="DocumentPort" binding="tns:DocumentBinding">
        <soap:address location="http://www.apollo.co.za/soap/test2server.php" />
    </port>
</service>

</definitions>

I am trying to define a simple wsdl document that has one operation "getDocument", that takes a user name string parameter and returns a string result. I am very new to SOAP and am struggling a bit to get to grips with it, so would really appreciate it if someone could point out what is wrong in my wsdl definition.


回答1:


Try type='xsd:string' instead of type="tns:InputUserType"

In hopes that examples are helpful, here's one that I use:

<?xml version='1.0' encoding='UTF-8' ?>
<definitions name='AddWidget'
  targetNamespace='urn:ANYTHINGHEREAddWidget'
  xmlns:tns='urn:ANYTHINGHEREAddWidget'
  xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
  xmlns:xsd='http://www.w3.org/2001/XMLSchema'
  xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
  xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
  xmlns='http://schemas.xmlsoap.org/wsdl/'>

<message name='AddWidgetRequest'>
  <part name='Auth_Username' type='xsd:string'/>
  <part name='Auth_Password' type='xsd:string'/>
  <part name='Widget_Name' type='xsd:string'/>
  <part name='Widget_Description' type='xsd:string'/>
</message>
<message name='AddWidgetResponse'>
  <part name='Result' type='xsd:string'/>
</message>

<portType name='AddWidgetPortType'>
  <operation name='AddWidget'>
    <input message='tns:AddWidgetRequest'/>
    <output message='tns:AddWidgetResponse'/>
  </operation>
</portType>

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

<service name='AddWidgetService'>
  <port name='AddWidgetPort' binding='tns:AddWidgetBinding'>
    <soap:address location='https://www.yoursite.com/en/Soap_Server.html'/>
  </port>
</service>
</definitions>


来源:https://stackoverflow.com/questions/7486703/php-soapclient-getfunctions-returning-unknown-types

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