[
https://issues.apache.org/jira/browse/XMLRPC-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12482079
]
Marcelo Grassi commented on XMLRPC-138:
---------------------------------------
Here is what i did:
First, i extends the StringSerializer and override the write method and passed
the TAG parameter:
import org.apache.xmlrpc.serializer.StringSerializer;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
public class StringSerializer2 extends StringSerializer {
/* (não-Javadoc)
* @see
org.apache.xmlrpc.serializer.StringSerializer#write(org.xml.sax.ContentHandler,
java.lang.Object)
*/
public void write(ContentHandler pHandler, Object pObject)
throws SAXException {
write(pHandler, STRING_TAG, pObject.toString());
}
}
After that, i created a custom factory.
If the instance of the parameter is String, i use the nem Serializer that i
override:
import org.apache.xmlrpc.common.TypeFactoryImpl;
import org.apache.xmlrpc.common.XmlRpcController;
import org.apache.xmlrpc.common.XmlRpcStreamConfig;
import org.apache.xmlrpc.serializer.TypeSerializer;
import org.xml.sax.SAXException;
public class MyTypeFactory extends TypeFactoryImpl {
public MyTypeFactory(XmlRpcController pController) {
super(pController);
}
public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object
pObject) throws SAXException {
if (pObject instanceof String) {
return new StringSerializer2();
} else {
return super.getSerializer(pConfig, pObject);
}
}
}
And then, in my client class, i set the factory that i created:
client.setTypeFactory(new MyTypeFactory(client));
Now the tag <String> is always writed in xml.
I have to do that because the Service that i´m using needs to receive the Tag
always.
Thanks for the help.
[]´s
> Error in xml write
> ------------------
>
> Key: XMLRPC-138
> URL: https://issues.apache.org/jira/browse/XMLRPC-138
> Project: XML-RPC
> Issue Type: Bug
> Components: Source
> Affects Versions: 3.0
> Environment: Java
> Reporter: Marcelo Grassi
>
> There is a issue in StringSerializer.java.
> The problem is when a parameter is an array of objects.
> When a object of this array is a String, the xmlrpc does not insert the
> <string></string> tag.
> The xmp-rpc specification says that the tag must be inserted !
> I found the method where is the problem.
> public void write(ContentHandler pHandler, Object pObject) throws
> SAXException {
> write(pHandler, null, pObject.toString());
> }
> I changed the null parameter to constant STRING_TAG and then the tag was
> inserted well.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.