1

I have to code a Web service client, compliant to Axis2 1.5.4. The part of code giving the problem is as follows:

String my_var = "some value";
MetaDataEntry metaDataEntry = MetaDataEntry.Factory.newInstance();
metaDataEntry.setKey(MetaDataKey.Enum.forInt(key));
metaDataEntry.setValue(my_var);

Now basically the setKey woks fine but setValue expects an XmlObject value while according to the sample response document I have got, the xml structure should be like :

....
    <MetaDataEntry>
        <key>some_key_enum</key>
        <value>some _value</value>
    </MetaDataEntry>
....

I've tried using :

MetaDataEntry.setValue(XmlObject.Factory.parse("<value>"+my_var+"</value>"));

but it formats the value tag as <value><value>some_value</value></value>. I've also tried :

metaDataEntry.setValue(XmlObject.Factory.parse(my_var));

but it gives the exception: Unexpected Element: CDATA. Can anybody please help me write the correct statement?

2
  • What does your XSD look like? Commented Feb 28, 2013 at 15:33
  • The only element having problem is value element. The value element is declared as xs:anytype. Now, when client code is generated through wsdl2java, an interface is created for MetaDataEntry element and inside that I have setValue method and that accepts XmlObject type of value. I am basically facing problem in how can i pass a simple text value in setValue method such that there is no nesting of value tag. Commented Feb 28, 2013 at 20:36

1 Answer 1

1

Try using an XmlString value:

metaDataEntry.setValue(XmlString.Factory.newValue(my_var));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.