How to access input parameters?

2009-02-06
2013-05-02
  • Daniel Meier
    Daniel Meier
    2009-02-06

    Hi

    I'm a beginner with ZSI (and SOAP as well). I managed to generate skeletons from my WSDL file and would like to create a server. This works, I can respond to the request, but I don't know where I can access the input parameters. For a better understanding, here is my code:

    from ZSI.ServiceContainer import AsServer
    from ProvisioningWebService_services_server import *

    class Service(ProvisioningWebService):
        def soap_getIpFromMac(self, ps):
            response = ns0.getIpFromMacResponse_Dec().pyclass()
            response._ip = '123.45.67.89'
            return response

    if __name__ == "__main__":
        AsServer(10000, (Service(),))

    So I'm sending back a SOAP message with one argument "ip", but how can I access the argument "mac" which comes with the request?

    Any help is highly appreciated!

    Daniel

     
    • Saravanan
      Saravanan
      2009-02-06

      I'm not sure of your WSDL definition.
      Here is the code to access request.

      ...

      from ZSI.ServiceContainer import AsServer
      from ProvisioningWebService_services_server import *

      class Service(ProvisioningWebService):
             def soap_getIpFromMac(self, ps, **kw):
                     req, resp = ProvisioningWebService.soap_getIpFromMac(self, ps, **kw)
             mac = req.get_element_mac()
             response = resp.new_response()
                     response._ip = '123.45.67.89'
                     return response

      if __name__ == "__main__":
             AsServer(10000, (Service(),))

       
    • Daniel Meier
      Daniel Meier
      2009-02-09

      Dear Saravanan

      Thank you for your response. I tried your code, but apparently I'm having an error in line 17 now. This is the SOAP fault I'm getting back:

      <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <SOAP-ENV:Header/>
         <SOAP-ENV:Body>
            <SOAP-ENV:Fault>
               <faultcode>SOAP-ENV:Server</faultcode>
               <faultstring>Processing Failure</faultstring>
               <detail>
                  <ZSI:FaultDetail>
                     <ZSI:string>iteration over non-sequence</ZSI:string>
                     <ZSI:trace>build/bdist.linux-i686/egg/ZSI/ServiceContainer.py:108:_Dispatch
      ProvServer.py:17:soap_getIpFromMac</ZSI:trace>
                  </ZSI:FaultDetail>
               </detail>
            </SOAP-ENV:Fault>
         </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Thank you for helping

       
    • Daniel Meier
      Daniel Meier
      2009-02-09

      Problem solved, I'm now using:

      from ZSI.ServiceContainer import AsServer
      from ProvisioningWebService_services_server import *

      class MyProvisioningWebService(ProvisioningWebService):
          _wsdl = "".join(open("ProvisioningWebService.wsdl").readlines())
         
          def soap_getIpFromMac(self, ps, **kw):
              response = ProvisioningWebService.soap_getIpFromMac(self, ps, **kw)
              request = self.request
              response._ip = self.getIpFromMac(request._mac)
              return response
         
          def getIpFromMac(self, mac):
              return '12.23.45.67'
                     
      AsServer(port=10000, services=[MyProvisioningWebService(),])