You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Antonio Di Ferdinando <di...@gmail.com> on 2009/04/24 16:24:36 UTC

Deserializing a String with Axis

 Hi,
I am new to Axis, and I am aware of the fact that the problem I am facing
will probably sound stupid to many of you. But it seems that I can't get out
of it, so I decided to give it a try.
The background for my problem is fairly complex, and thus I am jumping
straight to the problem: how do I deserialize a string using axis?

Suppose I have the following XML snippet in a Java string:

<fileName xsi:type=\"xsd:string\" xmlns:xsi=\"
http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"
http://www.w3.org/2001/XMLSchema\">My String!</fileName>"

Ideally, the deserialization should return an object with"My String!"
inside. I have written the code below (bear in mind that it is just proof of
concept):

Object strOut = sd.makeValue(myStr);

QName qname = *new* javax.xml.namespace.QName("
http://schemas.xmlsoap.org/soap/encoding/");

String myStr="<fileName xsi:type=\"xsd:string\" xmlns:xsi=\"
http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"
http://www.w3.org/2001/XMLSchema\">My String!</fileName>";

SimpleDeserializer sd = *new* SimpleDeserializer(String.*class*, qname);

Object strOut = sd.makeValue(myStr);

 System.*out*.println("Deserialized String is " + strOut.toString());

Unfortunately, it does not work and the output is an object containing the
original string (myStr). I am not actually sure the SimpleDeserializer is
what I need, nor really what is wrong with this code. Can anyone kindly help
me or point me to some resource where I can grasp the solution?

Thank you in advance.



Antonio.