0

I have been trying to create a web service out some python scripts, and haven't seemed to have had much luck. I am new to web services in general, but would really like to get this figured out. I'm on Windows 7 and use IIS7. The service also needs to be SOAP.

I've read through most posts that have anything to do with python and SOAP and tried out pretty much all the different libraries, but most of them just seem over my head (especially ZSI/SOAPpy). The Ladon Library seems like it would be best (and simplest) for what I need, but the tutorial http://www.youtube.com/watch?v=D_JYjEBedk4&feature=feedlik loses me at 5:10 when he brings it to the server. When I type the ladon2.6ctl in the cmd, it seems like windows gets quite confused. I'm guessing it is a little different because he is running on Linux and using Apache.

With that, any tips on how to get a python web service running on Microsoft 'stuff' would be greatly appreciated, as I have been trying to figure this stuff out for way too long.

One thing to note is the reason things are so specific (and seemingly strange) is because the scripts I have do a lot of geoprocessing with ESRI's "arcpy".

--Addition--

Traceback on localhost:8080/TestService:
Traceback (most recent call last):
  <br>File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\server\wsgi_application.py", line 229, in __call__
    exec("import %s" % ','.join(self.service_list))
  File "<string>", line 1, in <module>
  File "c:\Users\r\workspace\ladon\src\testspace.py", line 3, in <module>
    class TestService2(object):
  File "c:\Users\r\workspace\ladon\src\testspace.py", line 4, in TestService2
    @ladonize(int,int,rtype=int)
  File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\decorator.py", line 87, in decorator
    ladon_method_info = global_service_collection().add_service_method(f,*def_args,**def_kw)
  File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\collection.py", line 119, in add_service_method
    sinfo = self.source_info(src_fname)
  File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\collection.py", line 79, in source_info
    a = ast.parse(src)
  File "c:\Python26\ArcGIS10.0\lib\ast.py", line 37, in parse
    return compile(expr, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
     from ladon.ladonizer import ladonize

^
 SyntaxError: invalid syntax

sample code:

from ladon.ladonizer import ladonize

class TestService2(object):
    @ladonize(int,int,rtype=int)
    def sum(self,a,b):
        '''add two numbers<br>
        param a: number 1
        param b: number 2
        rtype: sum of result
        '''
        return a+b
joaquin
  • 82,968
  • 29
  • 138
  • 152
Royce
  • 1
  • 3

2 Answers2

1

I must admit I normally use Linux for almost everything and I haven't tried Ladon on Windows for a while. I will spin up my windows installation later today and see if there is any trouble.

You wrote that ladon2.6ctl get's confused. Do you have an exception Traceback?

Community
  • 1
  • 1
  • I just installed Ladon on windows. It turned out there were syslog import in 3 different ladon modules which I used months ago to debug the LadonWSGIApplication class. These syslog imports should have been removed after I was done but I forgot. Anyway syslog functions are not used anywhere so you can just remove them locally - ladon/interfaces/jsonwsp.py[6] ladon/dispatcher/dispatcher.py[7] ladon/server/wsgi_application.py[37]. I have ofcourse removed the imports from the sourcetree on launchpad.net so next release of Ladon 0.6.1 scheduled for august 1st should work out of the box. – Jakob Simon-Gaarde Jul 10 '11 at 12:16
  • I took the liberty of adding this as a [bug](https://bugs.launchpad.net/ladon/+bug/808331) - which is the right way to go about with a case like yours. I hope this helped :-) [Ladon in action on Windows](https://launchpadlibrarian.net/74903034/ladon-on-windows.png) – Jakob Simon-Gaarde Jul 10 '11 at 12:32
  • I added the traceback to the question, thank you very much for the help. – Royce Jul 10 '11 at 18:08
  • The last traceback looks like a syntax error in your serviceclass module - probably an indentation error. Try starting the python interpreter and import the module by hand. You upload your service module to pastebin.com if you want me to look at it. – Jakob Simon-Gaarde Jul 10 '11 at 20:19
  • it is on pastebin.com for 24 hours, titled "Ladon and Python". I don't think it is an indentation error. If the error is line one, maybe a problem importing ladon? Again, thank you for your help. – Royce Jul 11 '11 at 12:48
  • ok Royce I can see this is a python2.6 specific error. I am gonna find out why this happens now. Check back in an hour :-) – Jakob Simon-Gaarde Jul 11 '11 at 14:43
  • For some reason unknown python2.6's ast module does not accept `\r\n` as linefeeds when parsing. But all python versions after that do, so python 2.7 will work for the example you sent to me. Alternatively you can make sure the editor you are using uses `\n` as linefeed which will solve the problem in python 2.6 – Jakob Simon-Gaarde Jul 11 '11 at 15:13
  • Huh. so it is Python 2.6 and not me? That makes me feel better for sure. Unfortunately I won't be able to use Python 2.7 until ArcGIS 10.1 comes out early next year. Also, I do use the Eclipse SDK, does that matter at all? – Royce Jul 11 '11 at 17:17
  • No it is not you :-) and the reason I haven't experienced this problem is that I almost always use Linux and on all other systems than Windows it is most common to use `\n` not `\r\n` as linefeed. I hope you got it working now. Remember to use a webserver with WSGI support when you go into production. `ladon2.6ctl serve` should only be used for testing your web service. – Jakob Simon-Gaarde Jul 11 '11 at 17:19
  • It doesn't matter which IDE you use - just make sure the editor of the IDE saves files with `\n` - Eclipse: http://stackoverflow.com/questions/2374728/eclipse-editor-how-to-change-file-format-from-dos-to-unix – Jakob Simon-Gaarde Jul 11 '11 at 17:21
0

To summarize the fix for anyone else interested, delete the "syslog import" from these 3 ladon modules:
ladon/interfaces/jsonwsp.py - line 6
ladon/dispatcher/dispatcher.py - line 7
ladon/server/wsgi_application.py - line 37

Then, you need to change the linefeed from window's default of /r/n to /n. In Eclipse, go to Window -> Preferences -> General, then select (not drop down) the Workspace tab. On the bottom right, select "other" under New text file line delimiter and change it to Unix.

Royce
  • 1
  • 3