I have following code and my message is in xml formatted and it is huge data. I am not getting my message in and . Xml angle brackets are now transformed. I would like to have angle brackets rather than ampersand lt semicolon.
<createOrderRequestType xmlns:ns2="http://xmlns.oracle.com/communications/ordermanagement">
<msg><head></head>
</body>
</msg>
</createOrderRequestType>
<msg>
<head> </head>
<body> </body>
</msg>
public CreateOrderResponseType createAncillariesBySoloOrderId(String soloOrderId) {
String message = findOrderBySoloOrderId(soloOrderId);
final Pattern pattern = Pattern.compile("<msg xmlns=\"\">(.+?)</msg>", Pattern.DOTALL);
final Matcher matcher = pattern.matcher(message);
matcher.find();
String msgStr = matcher.group(1) ;
log.info("message = " + msgStr );
CreateOrderRequestType createOrderRequestType = new CreateOrderRequestType() ;
Document doc;
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element msg = doc.createElement("msg");
msg.setTextContent(msgStr);
doc.appendChild(msg);
createOrderRequestType.getAny().add((Element) doc.getFirstChild());
StringWriter sw1 = new StringWriter();
JAXB.marshal(createOrderRequestType, sw1);
String xmlString = sw1.toString();
log.info("xmlString = " + xmlString);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return getOSMService(osmServiceUrl).createOrder(createOrderRequestType);
}
public class CreateOrderRequestType {
@XmlAnyElement(lax = true)
protected List<Object> any;
public List<Object> getAny() {
if (any == null) {
any = new ArrayList<Object>();
}
return this.any;
}
}