2012-07-19 60 views
3

我目前正在嘗試提供基於SOAP RPC/Literal的Web服務。
這裏是我的WSDL文件:RPC /文字過程不存在

<?xml version="1.0" encoding="iso-8859-1"?> 
<!--WSDL genere permettant de decrire le service web.--> 
<!--Partie 1 : Definitions--> 
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" name="WSDL" targetNamespace="http://soap.mycompany.org/wsdl/" xmlns:typens="http://soap.mycompany.org/wsdl/" 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/"> 
    <!--partie 2 : Types--> 
    <types> 
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://soap.mycompany.org/wsdl/"> 
     <xsd:complexType name="calculatorAuthInput"> 
     <xsd:annotation> 
      <xsd:documentation>^CSoapHandler-calculatorAuth^</xsd:documentation> 
     </xsd:annotation> 
     <xsd:sequence> 
      <xsd:element name="operation" type="xsd:string"> 
      <xsd:annotation> 
       <xsd:documentation>^CSoapHandler-calculatorAuth-operation^</xsd:documentation> 
      </xsd:annotation> 
      </xsd:element> 
      <xsd:element name="entier1" type="xsd:integer"> 
      <xsd:annotation> 
       <xsd:documentation>^CSoapHandler-calculatorAuth-entier1^</xsd:documentation> 
      </xsd:annotation> 
      </xsd:element> 
      <xsd:element name="entier2" type="xsd:integer"> 
      <xsd:annotation> 
       <xsd:documentation>^CSoapHandler-calculatorAuth-entier2^</xsd:documentation> 
      </xsd:annotation> 
      </xsd:element> 
     </xsd:sequence> 
     </xsd:complexType> 
     <xsd:complexType name="calculatorAuthOutput"> 
     <xsd:sequence> 
      <xsd:element name="result" type="xsd:integer"> 
      <xsd:annotation> 
       <xsd:documentation>^CSoapHandler-calculatorAuth-result^</xsd:documentation> 
      </xsd:annotation> 
      </xsd:element> 
     </xsd:sequence> 
     </xsd:complexType> 
    </xsd:schema> 
    </types> 
    <!--partie 3 : Message--> 
    <message name="calculatorAuthRequest"> 
    <part name="parameters" type="typens:calculatorAuthInput"/> 
    </message> 
    <message name="calculatorAuthResponse"> 
    <part name="parameters" type="typens:calculatorAuthOutput"/> 
    </message> 
    <!--partie 4 : Port Type--> 
    <portType name="MyPort"> 
    <!--partie 5 : Operation--> 
    <operation name="calculatorAuth"> 
     <input message="typens:calculatorAuthRequest"/> 
     <output message="typens:calculatorAuthResponse"/> 
    </operation> 
    </portType> 
    <!--partie 6 : Binding--> 
    <binding name="MyBinding" type="typens:MyPort"> 
    <soap:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="calculatorAuth"> 
     <soap:operation xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" soapAction=""/> 
     <input name="calculatorAuthRequest"> 
     <soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/> 
     </input> 
     <output name="calculatorAuthResponse"> 
     <soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/> 
     </output> 
    </operation> 
    </binding> 
    <!--Partie 7 : Service--> 
    <service name="MyService"> 
    <documentation>Documentation du WebService</documentation> 
    <!--partie 8 : Port--> 
    <port name="MyPort" binding="typens:MyBinding"> 
     <soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="http://localhost/mywebsite/?login=1&amp;username=myusername&amp;password=mypassword&amp;m=webservices&amp;a=soap_server&amp;class=CSoapHandler&amp;suppressHeaders=1"/> 
    </port> 
    </service> 
</definitions> 

我想一切都是正確的,但似乎並不是因爲我發動我的SOAP客戶端時有此錯誤(我有soapUI的同樣的錯誤):

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Body> 
     <SOAP-ENV:Fault> 
     <faultcode>SOAP-ENV:Server</faultcode> 
     <faultstring>Procedure 'calculatorAuth' not present</faultstring> 
     </SOAP-ENV:Fault> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

這裏是我的SOAP客戶端的示例代碼:

<?php 
    // Désactivation du cache WSDL 
    ini_set("soap.wsdl_cache_enabled", "0"); 

    $client = new SoapClient("http://localhost/mywebsite/index.php?login=myusername:mypassword=webservices&a=soap_server&class=CSoapHandler&wsdl&wsdl_mode=CWSDLRPCLiteral", array("trace" => true)); 
    try { 
    echo "<pre>"; 
    $res = $client->calculatorAuth(array("operation" => "add", "entier1" => 888, "entier2" => 987654321)); 
    print_r($res); 
    } 
    catch (SoapFault $e) { 
    echo $e; 
    } 
?> 

我不明白爲什麼沒有找到我的程序。我徒勞地花了幾個小時來搜索我的WSDL中的問題。
我對這些技術還沒有真正的實驗,也許有人可以給我一個外部的看法?

回答

0

您沒有<xsd:complexType name="calculatorAuth">您的<types>聲明中的任何地方? 看來你正試圖調用一個不存在的方法。