RPC / Literal过程不存在

时间:2012-07-19 09:22:44

标签: php soap wsdl rpc procedure

我目前正在尝试提供基于SOAP RPC / Literal的Web服务 这是我的WSDL文件:

<?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中的问题。
我还没有真正尝试过这些技术,也许有人可以给我一个外部观点?

1 个答案:

答案 0 :(得分:0)

<xsd:complexType name="calculatorAuth">声明中的任何地方都没有<types>? 您似乎正在尝试调用不存在的方法。