Hi all,

I am trying to make a SOAP service in Django via soaplib(1.0.0 - beta
8) and consume the same service for testing purposes with SUDS (0.4).

I can consume external SOAP services with SUDS no problem, but am
running into problems when trying to consume my own service.

My service is as follows:

#soap_service.py file

import StringIO

from soaplib.service import rpc, DefinitionBase
from soaplib.serializers import primitive as soap_types

class DumbStringIO(StringIO.StringIO):
    def read(self, n):
        return self.getvalue()


class DjangoSoapService(DefinitionBase):

    __tns__ = 'http://127.0.0.1:8000'

    @rpc(soap_types.String, _returns=soap_types.String)
    def hello_world(self, hello_string):
        """
        Accepts primitive string and returns the same primitive.
        """
        return hello_string

Here is my website.views.py

class MySOAPService(Application):
    """
Creates a WSGI application interface to the SOAP service
"""
    def __call__(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
        environ = request.META.copy()
        body = request.raw_post_data
        environ['CONTENT_LENGTH'] = len(body)
        environ['wsgi.input'] = DumbStringIO(body)
        environ['wsgi.multithread'] = False
        response = super(MySOAPService, self).__call__(environ,
start_response)
        django_response.content = "\n".join(response)
        return django_response


my_soap_service = MySOAPService([DjangoSoapService],
DjangoSoapService.__tns__)

and here is my urls.py file:

urlpatterns += patterns('website.views',
    (r'^hello_world/', 'my_soap_service'),
    (r'^hello_world/service.wsdl',
'my_soap_service'),
)

I can view the wsdl file no problem, and it correctly shows my method
'hello_world'. However calling the method with suds from the python
shell thus:

>>>from suds.client import Client
client = ('http://127.0.0.1:8000/hello_world/service.wsdl',
cache=None)
response = client.service.hello_world('hi')

gives a stack:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Python/2.5/site-packages/suds-0.4-py2.5.egg/suds/
client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "/Library/Python/2.5/site-packages/suds-0.4-py2.5.egg/suds/
client.py", line 602, in invoke
    result = self.send(soapenv)
  File "/Library/Python/2.5/site-packages/suds-0.4-py2.5.egg/suds/
client.py", line 649, in send
    result = self.failed(binding, e)
  File "/Library/Python/2.5/site-packages/suds-0.4-py2.5.egg/suds/
client.py", line 708, in failed
    raise Exception((status, reason))
Exception: (403, u'FORBIDDEN')


No idea why it's not allowing me to connect, it's all local. Help!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to