ASP .NET web service and Django

118 views
Skip to first unread message

shar100101

unread,
May 24, 2014, 7:38:11 PM5/24/14
to django...@googlegroups.com
Hi,

How to create and send HTTP request from ASP .NET web service with POST data in it, to Django, and get HTTP responce from Django to web service ? Does anyone have a simple example of this?

Regards,
Dušan

Ariel Calzada

unread,
May 24, 2014, 9:47:59 PM5/24/14
to django...@googlegroups.com
hi

.net -----> django you should look tastypie

django -----> asp you should use python library named request

regards fron colombia
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a1c1aaf2-6dd9-4cf8-9131-b454d8dcf548%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Ariel Calzada

La Salvaje Esperanza

Éramos dioses y nos volvieron esclavos.
Éramos hijos del sol y nos consolaron
con medallas de lata.
Éramos poetas y nos pusieron a recitar
oraciones pordioseras.
Éramos felices y nos civilizaron.
Quién refrescará la memoria de la tribu.
Quién revivirá nuestros dioses.
Que la salvaje esperanza siempre sea tuya, querida alma inamansable.

-Gonzalo Arango-

shar100101

unread,
May 26, 2014, 11:09:19 AM5/26/14
to django...@googlegroups.com
Unfortunately Tastypie is not solution for me, because it uses Rest. I am using IronPython to run website and I still have not found solution to read Soap/Rest requests with IronPython.

I was hoping that output form .Net service, sent using HTTP, can be used in Django. I tried using WebRequest class but it didn't work.

Jani Tiainen

unread,
May 26, 2014, 11:21:00 AM5/26/14
to django...@googlegroups.com
You might be interested in suds library, it's basically lightweight SOAP stuff, it may work or it may not.
All depends quality of WSDL you do have.

And to my knowledge getting Django to run on IronPython requires some
hacks...
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/091eda56-74a2-4b41-aa15-4f9a0c465daa%40googlegroups.com.

Ilya Kazakevich

unread,
May 26, 2014, 11:34:00 AM5/26/14
to django...@googlegroups.com
Hello,

For web services (I believe you speak about SOAP web services) check:
* https://wiki.python.org/moin/WebServices (SOAP section). It has info about Python SOAP client and server libraries.
* For .NET (client) : http://stackoverflow.com/questions/1302525/how-to-use-a-wsdl

Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"

>-----Original Message-----
>From: django...@googlegroups.com
>[mailto:django...@googlegroups.com] On Behalf Of Ariel Calzada
>Sent: Sunday, May 25, 2014 1:48 AM
>To: django...@googlegroups.com
>Subject: ASP .NET web service and Django
>
>hi
>
>.net -----> django you should look tastypie
>
>django -----> asp you should use python library named request
>
>regards fron colombia
>
>El sábado, 24 de mayo de 2014, shar100101 <voodoo...@gmail.com
><javascript:_e(%7B%7D,'cvml','voodoo...@gmail.com');> > escribió:
>
>
> Hi,
>
> How to create and send HTTP request from ASP .NET web service with POST
>data in it, to Django, and get HTTP responce from Django to web service ? Does
>anyone have a simple example of this?
>
> Regards,
> Dušan
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
>"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
>email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/a1c1aaf2-6dd9-4cf8-9131-b45
>4d8dcf548%40googlegroups.com
><https://groups.google.com/d/msgid/django-users/a1c1aaf2-6dd9-4cf8-9131-b4
>54d8dcf548%40googlegroups.com?utm_medium=email&utm_source=footer> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>--
>
>Ariel Calzada
>Homepage: http://www.000paradox000.co
>Blog: http://blog.000paradox000.co
>
>
>La Salvaje Esperanza
>
>Éramos dioses y nos volvieron esclavos.
>Éramos hijos del sol y nos consolaron
>con medallas de lata.
>Éramos poetas y nos pusieron a recitar
>oraciones pordioseras.
>Éramos felices y nos civilizaron.
>Quién refrescará la memoria de la tribu.
>Quién revivirá nuestros dioses.
>Que la salvaje esperanza siempre sea tuya, querida alma inamansable.
>
>-Gonzalo Arango-
>
>
>--
>You received this message because you are subscribed to the Google Groups
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to
>django-users...@googlegroups.com.
>To post to this group, send email to django...@googlegroups.com.
>Visit this group at http://groups.google.com/group/django-users.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/CACVFg4vgj1jqLUKdqqjwnA3A
>t8DS-KkEptu2ceZMufjpRhuyXA%40mail.gmail.com
><https://groups.google.com/d/msgid/django-users/CACVFg4vgj1jqLUKdqqjwnA3
>At8DS-KkEptu2ceZMufjpRhuyXA%40mail.gmail.com?utm_medium=email&utm_
>source=footer> .

Vernon D. Cole

unread,
May 27, 2014, 7:51:16 AM5/27/14
to django...@googlegroups.com
Jani:

   Can you please provide a link to the "hacks" you mention for IronPython?  I am preparing to run django with IronPython3 and any information on what people did to make IronPython work would be helpful.
--
Vernon Cole

shar100101

unread,
May 28, 2014, 9:26:11 AM5/28/14
to django...@googlegroups.com
Thanks everyone. I will try using suds but if suds use C libs, like soaplib does (lxml ), than this wont work too.

@Vernon

I don't know for IronPython3. I didn't managed to set up Django 1.5, there was errors in Django six.py lib ("""Utilities for writing code that runs on Python 2 and 3""") exec_ function. There was problems with  -X:Frames and namespaces so I gave up on this.

I use this 'hacks':

IronPython 2.7.3
Django 1.4
IIS 7.5
.NET Framewok 4.0
NWSGI [http://nwsgi.codeplex.com]

I
* AttributeError: 'module' object has no attribute '_getframe'
Use startproject  and startproject with -X:Frames

II
*
STATIC_URL = 'static/' # not  '/static/'

III
To use nice Django URL, use wildcard mapping

<wsgi>            
    <pythonPaths>                                                                          
        <path path="C:\Program Files (x86)\IronPython 2.7\Lib" />      
        <path path="C:\Program Files (x86)\IronPython 2.7\Lib\site-packages" /> 
    </pythonPaths>                                                    
    <wildcard physicalPath="C:\inetpub\wwwroot\HelloWorld\helloworld\wsgi.py" />
</wsgi> 

While using wildcard mappings you will have some limitations in urls.py with regular expressions.
If you use named groups in mapping whole expression is got to be in the named group.
 And every expression is got to start with ^ and end with $.
e.g.
url(r'^(?P<notify>notify).*$', 'helloworld.views.reset_cache'), - this wan't work
url(r'^(?P<notify>notify)(?P<eventXml>.*)$', 'helloworld.views.reset_cache'), - this will work

IV
If you get something like this error wen loading images:
"Unable to translate bytes [FF] at index 0 from specified code page to Unicode."

then in Django static.py change
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\django\views\static.py
63 "response = HttpResponse(f.read(), mimetype=mimetype)" with
63 "response = HttpResponse(bytes(f.read()), mimetype=mimetype)"

V
If you use non-ascii caracters.
* 'Unicode Decode Error:' then change:
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\django\http\__init__.py
717     def next(self):
            chunk = self._iterator.next()
            if isinstance(chunk, unicode):
                chunk = chunk.encode(self._charset)
            return str(chunk)
to:         
        def next(self):
            chunk = self._iterator.next()
            if isinstance(chunk, unicode):
                chunk = chunk.encode('utf8').encode('utf8')
            return str(chunk, 'utf8')
           
VI
To use filebased cache, remove pickle.HIGEST_PROTOCOL in
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\django\core\cache\backends\filebased.py
try:         
    now = time.time()      
    pickle.dump(now + timeout, f, pickle.HIGHEST_PROTOCOL)
    pickle.dump(value, f, pickle.HIGHEST_PROTOCOL)
finally:

try:         
    now = time.time()      
    pickle.dump(now + timeout, f)
    pickle.dump(value, f)
finally:

VII
I do not use database. In order to create sqlite3 db use python

VIII
django/utils/functional.py

django 1.4:

#assert not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types."   
assert (str is unicode) or not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types."   
# This solve:    
#     AssertionError: Cannot call lazy() with both str and unicode return types.   
# https://bitbucket.org/jdhardy/django-ironpython/commits/b70eeacda60c




Reply all
Reply to author
Forward
0 new messages