2011-09-20 47 views
2

我想構建一個示例wsdl文件,將由PHP SoapClient讀取,雖然我的wsdl文檔排序的工作(它正常返回函數)仍然沒有正確的,因爲PHP的__getFunctions方法返回如下:PHP SoapClient __getFunctions()返回UNKNOWN類型

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

從什麼是這個函數返回它似乎是類型定義不是100%正確的,因爲該類型顯示爲未知。

<?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> 

我試圖定義具有一個操作「getDocument」一個簡單的WSDL文檔,這需要一個用戶名字符串參數,並返回一個字符串結果。我對SOAP很陌生,並且正在努力解決它,所以如果有人能指出我的wsdl定義中有什麼問題,我會非常感激。

+0

我也面臨着同樣的問題。你能告訴我這個XML文件在哪裏? –

回答

3

嘗試類型=「的xsd:字符串」,而不是類型=「TNS:InputUserType」

在希望的例子是有幫助的,這裏有一個,我使用:

<?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> 
+0

示例非常有幫助。你推薦的變化是現貨。 __getFunctions()的輸出現在看起來更好了。謝謝你的幫助,查理。 – BruceHill

+0

我也面臨同樣的問題。你能告訴我這個XML文件在哪裏? - @查理 –