At work we have a java backend that talks to python on some mobile devices. The mobile devices have no GUI, it's just pure string manipulation. All contact is initiated by the python; the java is just for listening and answering.
As such the python will send messages like:
message_name(field1, field2, field 3)
As strings. The listener then picks it up, finds the associated class for
message_name (which is defined in an XML file) and feeds it the fields. The class then feeds the listener a response which is just a csv like so:
response_field1, response_field2, response_field3
I'm not overly familiar with this kind of interface (or really any client-server interfaces), but I'm fairly sure it's not REST or SOAP. I'm not sure if it even has a name, or is simply a homegrown kind of thing. None of my coworkers have a name for it.
In response to comment by @moberemk the XML file looks something like this (for the above message/response):
<bean id="command_name" parent="base_request_class" class="the_class_that_takes_the_request" scope="prototype"> <property name="readOnly" value="true"/> <property name="commandName" value="message_name" /> <property name="response" ref="name_of_response_bean" /> <property name="args"> <list> <value>field1</value> <value>field2</value> <value>field3</value> </list> </property> </bean> <bean id="name_of_response_bean" class="base_response_class scope="prototype"> <property name="fields"> <list> <value>response_field1</value> <value>response_field2</value> <value>response_field3</value> </list> </property> </bean>
The listener makes note of this XML file. It then, upon receiving a message, looks for a relevant bean with "commandName" = "message_name" for whatever "message_name" came through. It then feeds the fields in the list of fields (args) to the class (given by the bean property "class"). Then the listener, once the thread for the class that takes the request has finished, takes the return result of that class and sends it verbatim to the python device.
So, if the listener were a human the process would go something like:
<receives message> <looks at message name> "Oh, it's a $message_name type of message. I know where to find who can help" <Looks up who handles that kind of message> <sends him the message with note "Let me know what you get back!"> <Guy that handles that message does his message handling, tells the listener what he found> <Listener returns that to the device>
With some python pseudocode...
def listener(self, cmd): parsed =  parsed = self.parse(cmd) #Array with ["name", "field1", "field2" ...] class = self.find_matching_class(parsed) #looks through the XML for the name of the class that should handle this message. String type executor = getattr(sys.modules[__name__], class) #Gets an instance of the class related to the message response = executor.execute(response[1:]) self.connection.sendall(response) #Sends the response created by the 'executor' class back to the device that asked for it