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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.