# soaplib v2.0.0beta2 (from memory)
# Django v1.3 (stable)
# NOTE: CSRF middleware has been turned off!
# For urls.py, see:
https://gist.github.com/935812
import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.model.clazz import Array
from django.views.decorators.csrf import csrf_exempt
class HelloWorldService(DefinitionBase):
@rpc(String,Integer,_returns=Array(String))
def say_hello(self, name, times):
results = []
for i in range(0, times):
results.append('Hellow, %s' %name)
return results
from soaplib.core.server.wsgi import Application
from django.http import HttpResponse
import StringIO
class DumbStringIO(StringIO.StringIO):
def read(self, n):
return self.getvalue()
@csrf_exempt
class DjangoSoapApp(Application):
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()
environ['CONTENT_LENGTH'] = len(request.raw_post_data)
environ['wsgi.input'] = DumbStringIO(request.raw_post_data)
environ['wsgi.multithread'] = False
# print help(DjangoSoapApp)
response = super(DjangoSoapApp, self).__call__(environ,
start_response)
django_response.content = '\n'.join(response)
return django_response
print type(DjangoSoapApp)
soap_application = soaplib.core.Application([HelloWorldService],
'tns')
#import pdb; pdb.set_trace()
hello_world_service = DjangoSoapApp(soap_application)
On Jul 5, 2:54 pm, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org>
wrote:
> Would you please provide the source for mysite.BDSCheckUser.views?
>
> _Nik
>
> On 7/5/2012 11:37 AM, Jeff Silverman wrote:
>
>
>
> > Resulting output,
>
> > Help on function DjangoSoapApp in module mysite.BDSCheckUser.views:
>
> > DjangoSoapApp(*args, **kwargs)
>
> > On Jul 5, 2:31 pm, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org>
> > wrote:
> >> Hmmm, I can't think of what may be happening. One more debug thing to
> >> try, print the help of DjangoSoapApp just before the problem line:
>
> >> print help(DjangoSoapApp)
>
> >> That way, if the DjangoSoapApp symbol is getting reassigned to a
> >> function somewhere along the way, that might clue you in.
>
> >> _Nik
>
> >> On 7/5/2012 11:17 AM, Jeff Silverman wrote:
>
> >>> I've been flip flopping my views.py between that snippet, and
> >>>
https://gist.github.com/935809, which is a bit different, but easier
> >>> to follow.
> >>> On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org>
> >>> wrote:
> >>>> Is your code still the same as you posted earlier:
http://djangosnippets.org/snippets/2638/?Andtheerror is occuring on