Hello,

when defining the _in_message property of a service operation, the operation 
cannot be called :

Considering the following server code:
------------------
from wsgiref.simple_server import make_server
from soaplib.core import Application
from soaplib.core.server import wsgi
from soaplib.core.model.primitive import String, Integer
from soaplib.core.service import DefinitionBase, soap

class BugService(DefinitionBase):
    ''' Sample service '''

    @soap(Integer,
          _public_name="urn:#getBugLabel",
          _in_message="getBugLabelMsgIn",
          _out_message="getButLabelMsgOut",
          _out_variable_name="bugLabel",
          _returns=String)
    def getBugLabel(self, bugCode):
        if bugCode == 0:
            return 'not a bug'
        else:
            return 'evil bug'



if __name__ == '__main__':
    soap_app = Application([BugService], 'http://example.com/bug', 
name='BugService')
    wsgi_app = wsgi.Application(soap_app)
    server = make_server('localhost', 7789, wsgi_app)
    server.serve_forever()
---------------

The produced WSDL looks correct :
---------------
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"; 
xmlns:tns="http://example.com/bug"; 
xmlns:plink="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"; 
xmlns:xop="http://www.w3.org/2004/08/xop/include"; 
xmlns:senc="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:s12env="http://www.w3.org/2003/05/soap-envelope/"; 
xmlns:s12enc="http://www.w3.org/2003/05/soap-encoding/"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
targetNamespace="http://example.com/bug"; name="BugService">
  <wsdl:types>
    <xs:schema targetNamespace="http://example.com/bug"; 
elementFormDefault="qualified">
      <xs:import namespace="http://www.w3.org/2001/XMLSchema"/>
      <xs:complexType name="getBugLabelMsgIn">
        <xs:sequence>
          <xs:element name="bugCode" type="xs:integer" minOccurs="0" 
nillable="true"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="getButLabelMsgOut">
        <xs:sequence>
          <xs:element name="bugLabel" type="xs:string" minOccurs="0" 
nillable="true"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="getBugLabelMsgIn" type="tns:getBugLabelMsgIn"/>
      <xs:element name="getButLabelMsgOut" type="tns:getButLabelMsgOut"/>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="getBugLabelMsgIn">
    <wsdl:part name="getBugLabelMsgIn" element="tns:getBugLabelMsgIn"/>
  </wsdl:message>
  <wsdl:message name="getButLabelMsgOut">
    <wsdl:part name="getButLabelMsgOut" element="tns:getButLabelMsgOut"/>
  </wsdl:message>
  <wsdl:portType name="BugService">
    <wsdl:operation name="getBugLabel" parameterOrder="getBugLabelMsgIn">
      <wsdl:input name="getBugLabelMsgIn" message="tns:getBugLabelMsgIn"/>
      <wsdl:output name="getButLabelMsgOut" message="tns:getButLabelMsgOut"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="BugService" type="tns:BugService">
    <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getBugLabel">
      <soap:operation soapAction="urn:#getBugLabel" style="document"/>
      <wsdl:input name="getBugLabelMsgIn">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getButLabelMsgOut">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="BugService">
    <wsdl:port name="BugService" binding="tns:BugService">
      <soap:address location="http://localhost:7789/wsdl"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
------------------

But when using suds to access the service, I get the following error:
suds.WebFault: Server raised fault: 'Method not found: 
'{http://example.com/bug}getBugLabelMsgIn'

The code for the client is:
-----------------
import logging
from suds.client import Client

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    logging.getLogger('suds.client').setLevel(logging.DEBUG)
    ws_client = Client('http://localhost:7789/wsdl', cache=None)
    res = ws_client.service.getBugLabel(2)
    print res

----------------

The request sent by the client is :
DEBUG:suds.client:sending to (http://localhost:7789/wsdl)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:ns1="http://example.com/bug"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:getBugLabelMsgIn>
         <ns1:bugCode>2</ns1:bugCode>
      </ns1:getBugLabelMsgIn>
   </ns0:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'"urn:#getBugLabel"', 
'Content-Type': 'text/xml; charset=utf-8'}


-----


Looking at the soaplib/core/_base.py module, it seems that the method name is 
retrieved by getting the first tag name of the SOAP Body (which is the input 
message name) rather than getting the SOAPAction of the HTTP header.

So, in order have the service responding correctly to requests, it is necessary 
that the input message name is the same as the operation name.


Antoine HUMBERT
_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap

Reply via email to