After a while using XmlRpc++, one of the failures that A. Dedov pointed (lack of UTF-8 support) is becoming more important to us in the project because of multilanguage support. As long as the input parameters are std::string values, it can be than the parsing, when using ASCII over the 127 does not work correctly.
As "workaround", I did the following:
- defined two new static functions XmlRpcUtil::ascii_to_utf8 and XmlRpcUtil::utf8_to_ascii
- Changed the XML header, adding encoding="UTF-8"
- Changed the functions XmlRpcValue::stringFromXml and XmlRpcValue::stringToXml to parse the input/output parameters (strings) between ASCII and UTF-8
I am trying to evaluate these changes risks. I would appreciate to hear your comments about the idea (in general) and the changes I mentioned.
If needed, I can also provide the source code
Thanks,
Jose Camacho
in Xml
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using xmlrpc++ to develop a xmlrpc C++ client. I use it with an xmlrpc Java server.
I have to send an array of strings from the client to the server. If I do this task from an xmlrpc Java client, of course, there is no problem.
But when I use the C++ client, I got this error message in the server side:
org.apache.xmlrpc.XmlRpcException: Failed to read XML-RPC request: Invalid byte 1 of 1-byte UTF-8 sequence.
The way I have coded the xmlrpc C++ client to send the strings array is:
I don't know what is happening, only that is related to the xml message codification. If you could tell me how I could solve the problem...
By the way, I am from Barcelona, I think you may speak spanish because of your name. If you don't understand something from this message I could mail you in spanish.
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
this message has nothing to do with the main subject (UTF as encoding), but I try to answer it anyway ;-)
I do not really understand your code. Maybe it is a copy-paste failure, I mean the playlist object is not used at all, instead of that, you transmit the arg list getting data from "param". In general, it is not a good idea to use "arg" as variable name...
Also, it is better assign single data, instead of the complete list in a "entry" of a XmlRpcValue object.
I think, your code should look like the following (I change the list for testing porposes)
Anyway, I write a problem I have got with this librery and I have had to solve. As a server aI use an XmlRpc Java server, hence, I use a Java library.
But I realized when I sent an array of elements (as in your example), the Java server got, for example, if I sent an array of two strings, two strings instead of a Java Vector. I had a look at the source code of XMLRPC++ library and I found the library doesn't code arrays. I mean, I didn't find the library did:
So I had to re-write a piece of source code. Now I only send arrays, but it is enough for me.
I have now a problem. XmlRpcValue object doesn't return size if they have no elements, that is, they never return size = 0. They only return size if they have elements.
I don't know if it is not possible but I have found nothing strange in XmlRpcValue header and I don't know whay it doesn't work. It would be very useful.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What I understood from your message:
- You are using XmlRpc++ library in your client side
- In the server side, you are using a "third party" XML-RPC library (not XmlRpc++ lib), developed in Java
To help you, I would need what exactly you want to send (better said, what the server expects to receive) and how your client source code is.
But, for documentation porpousses, please, open a new thread with this issue.
Jose
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
After a while using XmlRpc++, one of the failures that A. Dedov pointed (lack of UTF-8 support) is becoming more important to us in the project because of multilanguage support. As long as the input parameters are std::string values, it can be than the parsing, when using ASCII over the 127 does not work correctly.
As "workaround", I did the following:
- defined two new static functions XmlRpcUtil::ascii_to_utf8 and XmlRpcUtil::utf8_to_ascii
- Changed the XML header, adding encoding="UTF-8"
- Changed the functions XmlRpcValue::stringFromXml and XmlRpcValue::stringToXml to parse the input/output parameters (strings) between ASCII and UTF-8
I am trying to evaluate these changes risks. I would appreciate to hear your comments about the idea (in general) and the changes I mentioned.
If needed, I can also provide the source code
Thanks,
Jose Camacho
in Xml
Hello Jose,
I am using xmlrpc++ to develop a xmlrpc C++ client. I use it with an xmlrpc Java server.
I have to send an array of strings from the client to the server. If I do this task from an xmlrpc Java client, of course, there is no problem.
But when I use the C++ client, I got this error message in the server side:
org.apache.xmlrpc.XmlRpcException: Failed to read XML-RPC request: Invalid byte 1 of 1-byte UTF-8 sequence.
The way I have coded the xmlrpc C++ client to send the strings array is:
...
std::string playlist[10];
...
for(int i=0; i<10; i++){
playlist[i] = "test";
}
...
XmlRpcValue arg;
arg[0] = param;
...
I don't know what is happening, only that is related to the xml message codification. If you could tell me how I could solve the problem...
By the way, I am from Barcelona, I think you may speak spanish because of your name. If you don't understand something from this message I could mail you in spanish.
Thank you.
Hi,
this message has nothing to do with the main subject (UTF as encoding), but I try to answer it anyway ;-)
I do not really understand your code. Maybe it is a copy-paste failure, I mean the playlist object is not used at all, instead of that, you transmit the arg list getting data from "param". In general, it is not a good idea to use "arg" as variable name...
Also, it is better assign single data, instead of the complete list in a "entry" of a XmlRpcValue object.
I think, your code should look like the following (I change the list for testing porposes)
std::string playlist[10];
for(int i=0; i<10; i++)
{
playlist[i] = "test";
playlist[i] += i;
}
...
/* Main changes here */
XmlRpcValue xmlParams;
for (int i=0; i<10; i++)
xmlParams [i] = std::string (playlist[i]);
Try it and let us know, how now works.
Regards,
Jose
PS.- Yes, I can spanish, but I better write the answer in english for other people that can't
Thanks Jose, now it works perfectly.
Anyway, I write a problem I have got with this librery and I have had to solve. As a server aI use an XmlRpc Java server, hence, I use a Java library.
But I realized when I sent an array of elements (as in your example), the Java server got, for example, if I sent an array of two strings, two strings instead of a Java Vector. I had a look at the source code of XMLRPC++ library and I found the library doesn't code arrays. I mean, I didn't find the library did:
<array>
<data>
<value><string>Something here</string></value>
<value><string>Something here2</string></value>
<value><string>Something here3</string></value>
</data>
</array>
So I had to re-write a piece of source code. Now I only send arrays, but it is enough for me.
I have now a problem. XmlRpcValue object doesn't return size if they have no elements, that is, they never return size = 0. They only return size if they have elements.
I don't know if it is not possible but I have found nothing strange in XmlRpcValue header and I don't know whay it doesn't work. It would be very useful.
Thanks
What I understood from your message:
- You are using XmlRpc++ library in your client side
- In the server side, you are using a "third party" XML-RPC library (not XmlRpc++ lib), developed in Java
To help you, I would need what exactly you want to send (better said, what the server expects to receive) and how your client source code is.
But, for documentation porpousses, please, open a new thread with this issue.
Jose