这是将Java对象编组为SOAPMessage的代码:
public static SOAPMessage encode(String key,Object object) throws JAXBException, SOAPException{
JAXBContext airContext = newInstance("com.test");
contextMap.put("ws", airContext);
Marshaller marshaller = airContext .createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
marshaller.marshal(object, message.getSOAPBody());
message.saveChanges();
return message;
}
并且该对象喜欢:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Root {
private String name;
private String surname;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
我想将其封送至此xml:
test
但现在显示为:
<![CDATA[test]]>
test
你能告诉我这是怎么回事吗?