I submitted a patch to Hessian which enables it to run as both client
and server on GAE.  It works great, and is by far the easiest way to
implement web services on appengine.

Jeff

On Wed, Jan 13, 2010 at 2:35 PM, ujja <[email protected]> wrote:
> I will answer this by myself after playing around.
> It was in my case very straight forward using HttpURLConnection for
> the connection and SAXParser for handling the result. I have stripped
> out my details from the parser.
> The solution is fast and works on both simulator and uploaded on GAE.
>
> /Ulrik
>
> import java.io.InputStream;
> import java.io.OutputStreamWriter;
> import java.net.HttpURLConnection;
> import java.net.URL;
> import java.util.ArrayList;
> import java.util.List;
> import javax.xml.parsers.SAXParser;
> import javax.xml.parsers.SAXParserFactory;
> import org.xml.sax.Attributes;
> import org.xml.sax.InputSource;
> import org.xml.sax.SAXException;
> import org.xml.sax.helpers.DefaultHandler;
>
> public class XmlRpcHandler {
>
>        public MyData callRpc() throws Exception {
>                String message = "<?xml version=\"1.0\"?
>><methodCall><methodName>MyRpcMethod</
> methodName><params><param><value><string>myparamstring</string></
> value></param></params></methodCall>";
>
>                URL url = new URL("http://www.myserver.se/RPC2";);
>                HttpURLConnection connection = (HttpURLConnection) 
> url.openConnection
> ();
>                connection.setDoOutput(true);
>                connection.setRequestMethod("POST");
>        // Password handling, in my case MyPassword consisted of the
> string base64(user:password)
>                connection.setRequestProperty("Authorization", "Basic 
> MyPassword");
>                OutputStreamWriter writer = new OutputStreamWriter
> (connection.getOutputStream());
>                writer.write(message);
>                writer.close();
>                // Parse response xml
>                InputStream in = connection.getInputStream();
>                InputSource responseXML = new InputSource(in);
>                DefaultHandler myHandler = new DefaultHandler() {
>                        public void startElement(String uri, String localName, 
> String
> qName, Attributes attributes) throws SAXException {
>                                // Parser logic
>                        }
>                        public void characters(char [] buf, int offset, int 
> len) {
>                                String s = (new String(buf, offset, 
> len)).trim();
>                                // Parser logic, build mydata
>                        }
>                };
>
>                SAXParserFactory factory = SAXParserFactory.newInstance();
>                try {
>                        SAXParser parser = factory.newSAXParser();
>                        parser.parse(responseXML, myHandler);
>                } finally {
>                        in.close();
>                }
>
>                int res = connection.getResponseCode();
>                if (res != HttpURLConnection.HTTP_OK) {
>                        throw new Exception("HTTP POST did not respond with 
> OK, code:" +
> res);
>                }
>                return mydata;
>        }
> }
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine for Java" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
>
>
-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to