Re: Problems receiving a Python Server List in a Java Client
David ds <[email protected]>
| Newsgroups | gmane.text.xml.rpc.specification |
|---|---|
| Message-ID | <[email protected]> |
This is the client code:
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import
org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class Client{
public static void main(String args[]){
URL serverURL = null;
XmlRpcClientConfigImpl config = new
XmlRpcClientConfigImpl();
try{
serverURL = new URL("http://127.0.0.1:8000/xmlrpc");
}
catch(MalformedURLException e){
System.err.println("Invalid URL, ERROR in Client,
said: " + e.getMessage());
}
config.setServerURL(serverURL);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Vector parameters = new Vector();
parameters.add("According to the Collins English
Dictionary, a species is a class of plants or animals
whose members have the same main characteristics and
are able to breed with each other. The conundrum will
hang over a U.N. conference in Brazil next week where
experts will discuss ways to slow the loss of species.
The United Nations agreed in 2002 to reduce the rate
at which animals and plants are disappearing by
2010.");
try{
List result = (List)client.execute("guess_mood",
parameters);
System.out.println("RESULTADO: " +
result.toString());
List result2 = (List)client.execute("guess_topic",
parameters);
System.out.println("RESULTADO2: " +
result2.toString());
}
catch(XmlRpcException e){
System.err.println("Quering server, ERROR in Client,
said: " + e.getMessage());
}
}
}
And the whole error message I've got is the next one:
"Quering server, ERROR in Client, said: Failed to
parse servers response: Unexpected non-whitespace
character data"
The Python XML-RPC server seems to work well as I
don't implemented, it's from a tool I've downloaded
and I'm using. What server returns is a Python List:
output_pairs = [(class_names[i],classes[i]) for i in
range(len(class_names))]
output_pairs.sort(lambda
x,y:int(y[1]*100000-x[1]*100000))
return output_pairs
--- John Wilson <[email protected]> escribió:
>
> On 22 Mar 2006, at 19:19, David ds wrote:
>
> > Hi John,
> >
> > No, I'm not sending any String, the Python XMLRPC
> > Server is sending a Python List, but when I try to
> get
> > this data structure in the Java client I got the
> error
> > message I wrote in last mails, I don't know waht
> kind
> > of cast I have to do, it doesn't work ArrayLis,
> > neither List, Vector, Object[].
>
> So the error is being generated at the client end?
>
> Can you pleas post the exact message (cut and past
> if possible).
>
>
> John Wilson
> The Wilson Partnership
> web http://www.wilson.co.uk
> blog http://eek.ook.org
>
>
>
>
>
> Yahoo! Groups Links
>
>
> [email protected]
>
>
>
>
>
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/xml-rpc/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/