[Soap-Python] =?utf-8?Q?Re=3A_?=soaplib 1.0.0-beta6 - Integration with Django

Ben Lopatin ben.lopatin at wellfireinteractive.com
Wed Oct 6 04:31:52 CEST 2010


        
        
        Burak,The primary problem with this particular client application was that the soaplib WSDL declared the minOccurs attribute value for a response value as '0'. I'm not sure to what degree that was a .NET issue and a specific client application issue (I tried against what I understood to be third-party .NET testing services and by and large they fared okay).I would add that .NET compatability is probably important for most SOAP applications, as if you're dealing with services or clients that require SOAP you're probably dealing with 'enterprise' systems which all too often means .NET.I'd be happy to add that example into my fork. I'll see how it fares with the latest updates.Ben
        
		
		
        On Tuesday, October 5, 2010 at 10:21 AM, Burak Arslan wrote:
        
            

    On 10/05/10 16:54, Ben Lopatin wrote:
    
      All,
      
      
      I haven't looked at what's changed from 0.9.2 to 1.0, but here's a
      generalization of how I used soaplib 0.9.2 with Django: http://gist.github.com/499210
      
        
      
    
    fwiw, i didn't dare taking soaplib into production before 1.0. 
    
    at first glance, i think this should work. can you contribute this
    in the 1_0 examples directory in a fork of yours so that i pull it
    and have a look at it? (adding a small readme on how to get it
    running would also be helpful)
    
      The only thing that I had to work around was a finicky .NET
        client consumer, for which I wrote a modified static WSDL file.
        
        
      
    
    can you elaborate on this? does it have anything to do with
    http://github.com/arskom/soaplib/issues#issue/7 ?
    
    thanks
    burak
    
      
        Ben
        
          On Tue, Oct 5, 2010 at 9:43 AM, Devin
            Venable <venable.devin at gmail.com>
            wrote:Burak,
              
              
              The cat's out of the bag and there are a number of
                people using the Django integration recipe.  When I
                upgraded to soaplib 1.0 my Django integration also quit
                working, and it was based on the same snippet that Nick
                mentioned.
              
              
              Nick should check out http://djangosnippets.org/snippets/2210/,
                which is an updated snippet that shows the correct (or
                at least workable) way to do it using soaplib 0.9 or
                greater.  This worked for me.
              
              
              Devin
                
                
                  
                    On Tue, Oct 5, 2010 at 8:33 AM,
                      Burak Arslan <burak.arslan at arskom.com.tr>
                      wrote:
                    
                  
                    
                      
                        
                          
                             On 10/05/10 15:47, Nick Ruiz wrote:
                              Hi everyone,
                                
                                There is documentation online on how to
                                create web services with soaplib 0.8
                                within a Django web application, but the
                                code needs to be rewritten to work with
                                soaplib 1.0.0-beta6. I tried updating my
                                code to get a slightly-modified hello
                                world web service working under a Django
                                installation, but I receive the
                                following error:
                                
                                Error was:
                                'serverland.dashboard.api.views.worker_service'
                                is not a callable.
                                
                                Here is my base class for creating web
                                services (soap_handler):
                                
                                from soaplib.service
                                  import DefinitionBase
                                from soaplib.service
                                  import rpc
                                from
                                  soaplib.serializers import primitive
                                  as soap_types
                                
                                from django.http
                                  import HttpResponse
                                
                                class
                                  DjangoSoapApp(DefinitionBase):
                                
                                    def
                                  call_wrapper(self, request):
                                       
                                  django_response = HttpResponse()
                                        def
                                  start_response(status, headers):
                                            status,
                                  reason = status.split(' ', 1)
                                           
                                  django_response.status_code =
                                  int(status)
                                            for
                                  header, value in headers:
                                               
                                  django_response[header] = value
                                        response =
                                  super(DefinitionBase,
                                  self).call_wrapper(request.META,
                                  start_response)
                                       
                                  django_response.content =
                                  "\n".join(response)
                                
                                        return
                                  django_response
                                
                                Here is my service (created in views.py
                                of my Django app):
                                
                                from soap_handler
                                  import DjangoSoapApp, rpc, soap_types
                                from
                                  soaplib.serializers.clazz import Array
                                
                                class
                                  WorkerService(DjangoSoapApp):
                                
                                    __tns__ = 'http://my.namespace.org/soap/'
                                
                                   
                                  @rpc(soap_types.String,
                                  soap_types.Integer,
                                  _returns=Array(soap_types.String))
                                    def
                                  say_hello(self, name, times):
                                        results = []
                                        for i in
                                  range(0, times):
                                           
                                  results.append('Hello, %s'%name)
                                        return results
                                
                                worker_service =
                                  WorkerService()
                                
                                And here are my url pattern definitions:
                                    url(r'^soap/',
                                  'serverland.dashboard.api.views.worker_service'),
                                   
                                  url(r'^soap/service.wsdl',
                                  'serverland.dashboard.api.views.worker_service')
                                
                                How should I modify the DjangoSoapApp to
                                enable my web service to be callable
                                within Django?
                                
                              
                            
                          
                          i have never worked with django before.
                          consequently the error does not mean anything
                          to me.
                          
                          however, this bit is quite weird:
                          
                            
                                    response =
                              super(DefinitionBase,
                              self).call_wrapper(request.META,
                              start_response)
                                   
                              django_response.content =
                              "\n".join(response)
                            
                          
                          the response is not a string, but a native
                          python object. you should call the
                          corresponding to_xml to deobjectify that, and
                          call etree.tostring on that to serialize it to
                          a string. look at what happens in wsgi.py
                          after the call_wrapper is called.
                          
                          can't django just map wsgi application to a
                          url regex? i'd do it that way.
                          
                          fwiw, i'm working on soaplib 2.0 which will be
                          transport-agnostic. you could as well wait for
                          that to stabilize.
                          
                          best,
                          burak
                          
                          
                        
                        
                      
                    
                    _______________________________________________
                    Soap mailing list
                    Soap at python.org
                    http://mail.python.org/mailman/listinfo/soap
                    
                  
                
              
              
              _______________________________________________
              Soap mailing list
              Soap at python.org
              http://mail.python.org/mailman/listinfo/soap
              
            
          
          
          
          -- 
          Ben Lopatin
          www.wellfireinteractive.com
          ben.lopatin at wellfireinteractive.com
          571.482.8801
        
      
    
  

_______________________________________________Soap mailing listSoap at python.orghttp://mail.python.org/mailman/listinfo/soap
			
			
			
			
        
		
		
    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/soap/attachments/20101005/caa076bd/attachment.html>


More information about the Soap mailing list