WSF/Jython (Web Services Framework for Jython) is the latest addition to the impressive SOA stack at WSO2. It provides an amazingly simple approach to write web services as well as consume web services using Jython. As with all other products at WSO2, it is released under the Apache License hence you can download it and give it a try.There are two packages that comes with this release, the server side and the client side.
Client Side Features
Support for invoking Web Services in a simple clean manner
Ability to use WS-Addressing when invoking services
Ability to invoke services which require WS-Security
Ability to send binary attachments using MTOM
Server side Features
Support for exposing services written in Jython
-
DataBinding support using a simple annotation mechanism
-
Automated WSDL generation
- Ability to expose all enterprise features of Axis2 to services written in Jython
#@annotate("returns=int", "operationName=add", var1="integer", var2="integer")
def add(var1,var2):
return var1+var2
You could refer the article Deploying Python Services for more details.
Now lets see how easy it is to write a client for the service that we just wrote.
from org.wso2.wsf.jython.client import WSClient
from org.wso2.wsf.jython.client import WSFault
from org.wso2.wsf.jython.client import WSMessage
req_payload_string = "" 1 2
END_POINT = "http://localhost:8080/axis2/services/simpleService"
try:
client = WSClient({ "to" : END_POINT}, "")
req_message = WSMessage(req_payload_string, {})
print " Sending OM : " , req_payload_string
res_message = client.request(req_message)
print " Response Message: " , res_message
except WSFault, e:
e.printStackTrace();
You could execute this client by simple running the "wsfjython" shell script as follows,
sh wsfjython.sh /opt/software/wsf-jython-client-1.0-alpla/samples/myClient.py
For more details on writing clients and usage of advanced features please refer the article "Invoking Enterprise Web Services using Jython".
2 comments:
I have a question on the payload, our webservice - takes in username, pwd and token.
Signature:
login(username, pwd, string token)
ENDPOINT : https://sdfdsf:9300/LoginService
Now how do I know what is the payload xml ?
Thanks
need to integrate Jython web app with spring middle layer & hibernate for as backend.
is it feasible.?
Post a Comment