Kuddi: xmlrpc'ing vectors
"Henrik Plate \(GMX\)" <[email protected]> Thu, 6 Mar 2003 20:32:31 +0100
| Newsgroups | gmane.comp.java.enhydra.kxmlrpc |
|---|---|
| Message-ID | <[email protected]> |
Hi! According to some postings in http://www.mail-archive.com/[email protected]/maillist.html exactly the same question must have been posted in this list in sep 2002. Sorry for this, but unfortunatly the kxmlrpc mailing-list archive is not available. Any idea, when the archive is going to work again? Greetings, Henrik > -----Urspr=FCngliche Nachricht----- > Von: Henrik Plate (GMX) [mailto:[email protected]] > Gesendet: Donnerstag, 6. M=E4rz 2003 17:43 > An: [email protected] > Betreff: xmlrpc'ing vectors > > > Hi everybody! > > Beside (k)XMLRPC is really lightweight, easy to use/learn and > efficient I do have some problems transfering vectors from a > XMLRPC server to a MIDlet. > > I've got a servlet (source below, modified Apache class > org.apache.xmlrpc.XmlRpcProxyServlet) which acts as a XMLRPC > server. The servlet itself is registered as the default handler > and got the method getProviders, which simply returns a newly > constructed Vector. Other methods like getServerInfo, which > returns a String, succeed. > > When I call the servlet with a J2SE client (slightly modified > Apache example) the resulting object is a Vector. Fine. > > When I call the method from a MIDlet, the Wireless Toolkit prints > the following exception: > > org.kxml.io.ParseException: unexpected: StartTag <data> line: -1 > attr: null @-1:-1 > at org.kxml.parser.AbstractXmlParser.read(+53) > at org.kxmlrpc.XmlRpcParser.parseValue(+15) > at org.kxmlrpc.XmlRpcParser.parseArray(+23) > at org.kxmlrpc.XmlRpcParser.parseValue(+241) > at org.kxmlrpc.XmlRpcParser.parseParams(+46) > at org.kxmlrpc.XmlRpcParser.parseResponse(+144) > at org.kxmlrpc.XmlRpcClient.execute(+200) > at midlet.ServerConnection.callMethod(+15) > at midlet.XmlRpcTestControl$1.run(+18) > > The via HTTP transfered xml response of the servlet is > > <?xml version=3D"1.0" encoding=3D"ISO-8859-1"?> > <methodResponse> > <params> > <param> > <value> > <array> > <data> > <value>String 1</value> > <value>String 2</value> > </data> > </array> > </value> > </param> > </params> > </methodResponse> > > Seems to be OK. > > Does kXMLRPC miss the implementation of Vector transfers? I can't > imagine, cause the parser fails at the data-, not the array-tag. > Is it versioning problem? > > Here's my enviroment: > > kXMLRPC 0.6 > XMLRPC 1.1 from Apache > J2SE 1.4.1 > Tomcat 4.0.1 > > Relevant part of the servlet source: > > import org.apache.xmlrpc.*; > > public class XmlRpcServlet extends HttpServlet { > > // The xml-rpc server. > final XmlRpcServer server =3D new XmlRpcServer(); > > public void init(ServletConfig config)throws ServletException{ > > // Config the xml-rpc server. > XmlRpc.setDebug(true); > server.addHandler("$default", this); > } > > public String getServerInfo() { return "XmlRpcServlet"; } > //"$Name$"; } > > public Vector getProviders() { > final Vector v =3D new Vector(); > v.add("String 1"); > v.add("String 2"); > return v; > } > > public void service(HttpServletRequest req, > HttpServletResponse res)throws ServletException, IOException{ > byte[] result =3D server.execute(req.getInputStream ()); > res.setContentType("text/xml"); > res.setContentLength(result.length); > OutputStream output =3D res.getOutputStream(); > output.write(result); > output.flush(); > } > } > > Another question: If a XMLRPC call fails, the XmlRpcClient class > returns the result of the previous call. Is that desireable? Not > sure of this. > > Greetings und thanks in advance, > Henrik > > > > > > >