Skip to main content

unable to marshal type "java.lang.String" as an element because it is missi

2 replies [Last post]
juanavelez
Offline
Joined: 2008-09-16
Points: 0

I have created JAXB Objects off the SOAP 1.1 and SOAP 1.2 XSDs using XJC. I am creating a SOAP Envelope and setting the soap body to a string representing the contents (anything). When I try to marshal (convert it to a string), I get

unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation

Any advice on this?

Thanks,

Juan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ramapulavarthi
Offline
Joined: 2004-06-01
Points: 0
juanavelez
Offline
Joined: 2008-09-16
Points: 0

Thanks for the info, but this is not really the same case. The SOAP Schema specifies that the SOAP Body be anything, . I am assigning a string representation of a random SOAP body, and I want to marshal the SOAPEnvelope as I need to send a soap message on the wire. I understand that I may need to have to add the XmlRootElement annotation to an object if I need to do something with that object, but in this case I just need to assign a body to my SOAP message and then get the string representation of such SOAP message.