Steffen
Steffen

Reputation: 733

Backend for SOAP in Python

I am a Python programmer, but new to webservices.

Task:

I have a Typo3-Frontend and a Postgresql-database. I want to write a backend between these two parts in Python. Another developer gave me a wsdl-file and xsd-file to work with, so we use SOAP. The program I code should be bound to a port (TCP/IP) and act as a service. The data/payload will be encoded in json-objects.

    Webclient <---> Frontend <---> Backend(Me) <---> Database

My ideas:

  1. I code all functions by hand from the wsdl-file, with the datatypes from xsd.
  2. I bind a service to a port that recieves incoming json-data
  3. I parse the incoming data, do some database-operations, do other stuff
  4. I return the result to the frontend.

Questions:

  1. Do I have to code all the methods/functions descripted in the wsdl-file by hand?
  2. Do I have to define the complex datatypes by hand?
  3. How should I implement the communication between the frontend and the backend?

Thanks in advance!

Steffen

Upvotes: 2

Views: 1457

Answers (3)

Aleš Kotnik
Aleš Kotnik

Reputation: 2724

I have successfully used suds client to communicate with Microsoft Dynamics NAV (former Navision).

Typical session looks like this:

from suds.client import Client
url = 'http://localhost:7080/webservices/WebServiceTestBean?wsdl'
client = Client(url)

By issuing print client you get the list of types and operations supported by the serivce.

Suds - version: 0.3.3 build: (beta) R397-20081121

Service (WebServiceTestBeanService) tns="http://test.server.enterprise.rhq.org/"
   Prefixes (1):
     ns0 = "http://test.server.enterprise.rhq.org/"
   Ports (1):
     (Soap)
       Methods:
         addPerson(Person person, )
         echo(xs:string arg0, )
         getList(xs:string str, xs:int length, )
         getPercentBodyFat(xs:string name, xs:int height, xs:int weight)
         getPersonByName(Name name, )
         hello()
         testExceptions()
         testListArg(xs:string[] list, )
         testVoid()
         updatePerson(AnotherPerson person, name name, )
   Types (23):
     Person
     Name
     Phone
     AnotherPerson

WSDL operations are exposed as ordinary python functions and you can use ordinary dicts in place of WSDL types.

Upvotes: 3

emigue
emigue

Reputation: 502

You can use Python libraries as SOAPpy or PyWS.

Upvotes: 0

poof
poof

Reputation: 69

I would go with Twisted since I am working with it anyway and enjoy the system.

Another asynchronous option may be Tornado.

Or a synchronous version with Flask.

I'm sure there are many other options. I would look for a higher level framework like those listed above so you don't have to spend too much time connecting the frontend to the backend.

Upvotes: 1

Related Questions