[英]Xml angle brackets are changed to ampersand lt semicolon
I have following code and my message is in xml formatted and it is huge data.我有以下代码,我的消息是 xml 格式的,它是巨大的数据。 I am not getting my message in and .
我没有收到我的消息 和 。 Xml angle brackets are now transformed.
Xml 尖括号现在已转换。 I would like to have angle brackets rather than ampersand lt semicolon.
我想要尖括号而不是与号 lt 分号。
<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;
}
}
It depends of XSD这取决于 XSD
But, i think it will be:但是,我认为它将是:
...
@XmlRootElement(name = "CreateOrderRequestType") // or probably (name = "CreateOrderRequest")
public class CreateOrderRequestType {
...
and for response too也为了回应
...
@XmlRootElement(name = "CreateOrderResponseType") // or probably (name = "CreateOrderResponse")
public class CreateOrderResponseType{
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.