How to craft a response that matches a specification?

Asked by Alex Railean

I am having some trouble figuring one an aspect of using Ladon.

The documentation and the examples make it clear how to create a service from scratch and I have no questions about that. But I am not sure what the best approach is when there is a WSDL that specifies how the requests and responses should be formed.

For example, please have a look at this sample response: http://pastebin.com/TnL3iXNL

1. must I create a custom data type to be able to include objects such as "MobileUser" into the response?
2. how to ensure that the names of the elements match their counterparts in the SOAP/XML response?

To be more specific, I use a camelCase convention and variables always start with a small letter. In this example, however, the names are different: "UserIdentifier" and "MSISDN" (whereas in my notation they would be "userIdentifier" and "msisdn").

Does this mean that I will have to adjust my coding style to that of the responses? I hope that can be avoided, because there are inconsistencies (ex: "XMLSignature" and "MSS_Signature" - note the underscore) which will affect the uniformity of my own code.

Question information

Language:
English Edit question
Status:
Answered
For:
ladon Edit question
Assignee:
jsgaarde Edit question
Last query:
Last reply:
Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#1

Hi Alex.

To make a SOAP ComplexType (MobileUser in your example), you should use the LadonType abstract class:

http://packages.python.org/ladon/ladontype.html

I don't know what you mean with the next question about naming conventions. Ladon will call the elements exactly what you tell it to - given the following exception:
About the underscore - it is most common that SOAP clients expect non-underscore elements, indeed it is most likely that they will convert underscored elements to dashes. Ladon mimics this behaviour and converts underscores to dashes when creating XML for WSDL and SOAP responses. It also expects clients to send dashes instead of underscores. This way of handling underscores is very common among SOAP toolkits, ex: gSOAP and Suds

Best regards
Jakob Simon-Gaarde

Revision history for this message
Alex Railean (gr8dude) said :
#2

Thanks for the response, I have read the information about LadonType and I've seen the examples.

They make it clear how to return a complex structure, but I found no illustrations of how to take one of these at the input. Originally it was difficult for me to wrap my brain around it, though it turned out to be easy.

Maybe you could extend the samples such that they contain a case like this one, so beginners would find it right away. At this moment, all the examples only take primitive types at the input.

class ResponseDSearch(LadonType):
 clid = unicode
 certificate = unicode
 caChain = unicode
 responseCode = int

class RequestDSearch(LadonType):
 clid = unicode
 raid = int
 includeCaChain = bool

class CoreService(object):
 """
 The core class of the service that interfaces with the world
 """

 @ladonize(RequestDSearch, rtype = ResponseDSearch)
 def Search(self, request, **exports):
  """Search for data in LDAP"""
  print request.raid
  print exports['REMOTE_ADDR']
  result = ResponseDSearch()
  result.responseCode = request.raid+1
  return result

Can you help with this problem?

Provide an answer of your own, or ask Alex Railean for more information if necessary.

To post a message you must log in.