Winter Break with Google App Engine, Google Web Toolkit, ZSI.

For winter break I decided to test some things that I've had in the back log for a while. These things are Google App Engine, Google Web Toolkit, ZSI.

I really like the new technologies that Google is implementing. I personally aren't a fan of javascript, and the way they have managed to hide a lot of it through the use of GWT is amazing, and can actually make you more productive.

Basically what GWT empowers you to do is build an UI pretty much like you would in AWT in Java, this is great for doing basic widgets, like those used in Web Dynpro in SAP. And you can modify their colors and characteristics with CSS aswell.

So you can mostly focus on your code and develop stuff faster.

I'm not a big fan of JSON and would like to avoid it. python-gwt-rpc looks promising.

Another tool I reviewed was Google App Engine. I can say it is amazing, I like it, just like it. Maybe I'm biased because I like python programming.I also went on to mess around a bit with ZSI, which is the python soap web service engine I suppose. Although documentation is scarce; got to add up pieces to get it to do what you need.I wanted to put a web server on python cgi, so I started writing a small wsdl:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <wsdl:definitions xmlns:wsdl=""
  3. xmlns:soap=""
  4. xmlns:http="" xmlns:xs=""
  5. xmlns:soapenc=""
  6. xmlns:mime="" xmlns:tns=""
  7. targetNamespace="">
  8. <wsdl:types>
  9. <xs:schema targetNamespace="" elementFormDefault="qualified"/>
  10. </wsdl:types>
  11. <wsdl:message name="currentRequest">
  12. <wsdl:part name="voltage" type="xs:double"/>
  13. <wsdl:part name="resistance" type="xs:double"/>
  14. </wsdl:message>
  15. <wsdl:message name="currentResponse">
  16. <wsdl:part name="current" type="xs:double"/>
  17. </wsdl:message>
  18. <wsdl:portType name="CurrentServer">
  19. <wsdl:operation name="Current">
  20. <wsdl:input message="tns:currentRequest"/>
  21. <wsdl:output message="tns:currentResponse"/>
  22. </wsdl:operation>
  23. </wsdl:portType>
  24. <wsdl:binding name="CurrentServer" type="tns:CurrentServer">
  25. <soap:binding style="rpc" transport=""/>
  26. <wsdl:operation name="Current">
  27. <soap:operation soapAction="Current" style="rpc"/>
  28. <wsdl:input><soap:body use="encoded" encodingStyle="" namespace=""/></wsdl:input>
  29. <wsdl:output><soap:body use="encoded" encodingStyle="" namespace=""/></wsdl:output>
  30. </wsdl:operation>
  31. </wsdl:binding>
  32. <wsdl:service name="CurrentServer">
  33. <wsdl:port name="CurrentPort" binding="tns:CurrentServer"><soap:address location=""/></wsdl:port></wsdl:service></wsdl:definitions>

Then I applied wsdl2py from a python 2.5 installation script's dir on it. From it I grabbed the output python files

Uploaded it to the location along with ZSI in a directory

  1. #!/usr/local/bin/python -d
  2. from CurrentServer_server import *
  3. from ZSI import *
  4. import sys
  5. serialized_result = ""
  7. try:
  8. ps = ParsedSoap(sys.stdin)
  9. curr = ps.Parse(currentRequest.typecode)
  10. sw = SoapWriter(sys.stdout)
  11. result = currentResponse()
  12. result._current = curr._voltage / curr._resistance
  13. sw.serialize(result,currentResponse.typecode)
  14. sw.close()
  15. serialized_result = str(sw)
  17. except ParseException, e:
  18. FaultFromZSIException(e).AsSOAP(OUT)
  19. except Exception, e:
  20. FaultFromException(e, 1).AsSOAP()
  22. if len(serialized_result) > 0:
  23. print 'Content-type: text/xml'
  24. print
  25. print serialized_result
  26. else:
  27. print 'Content-type: text/plain'
  28. print
  29. print 'This is a place holder for a webservice'

Surprisingly, that is all that is needed on the server side.

I also wrote a test client on python and on c# .net to make sure it worked correctly.

Code for C#

Added webreference using the wsdl then...

using zsitesting.linuxReal; // namespace of the webreference

  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3. c = new CurrentServer(); // form loader
  4. }
  6. private void button1_Click(object sender, EventArgs e)
  7. {
  8. // this is just a button on a 3 textbox form
  9. double d1 = Double.Parse(textBox1.Text);
  10. double d2 = Double.Parse(textBox2.Text);
  11. textBox3.Text = c.Current(d1,d2).ToString();
  12. }

The python client requires to use wsdl2py and grab the client side files for current server.

  1. from CurrentServer_client import *
  2. import sys
  4. loc = CurrentServerLocator()
  5. port = loc.getCurrentPort(tracefile=sys.stdout)
  7. msg = currentRequest()
  8. msg._resistance = 1.5
  9. msg._voltage = 2.0
  11. rsp = port.Current(msg)
  12. print "current: ", rsp._current

There are a few other items that I'm currently working on regarding exploration. Mainly messing with django and google app engine, the google datastore, etc.

Have been playing around with my pic16f84a and learning more about electronics, I guess that could be called a hobby of mine now a days.