我解組像下面JAXB解組返回null
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<m:soResponse SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:m="urn:tec">
<Error/>
<Order>
<Number>6</Number>
</Order>
</m:soResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP消息的響應,並且即時結合JAXB註釋作爲
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"body"
})
@XmlRootElement(name = "Envelope")
public class Envelope {
@XmlElement(name = "Body", namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
protected Body body;
//......
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"soResponse"
})
@XmlRootElement(name = "Body")
public class Body {
@XmlElement(namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
protected soResponse;
//-----------
}
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"error",
"order"
})
@XmlRootElement(name = "soResponse")
public class soResponse{
@XmlElement(name = "Error", required = true)
protected soResponse.Error error;
@XmlElement(name = "Order", required = true)
protected soResponse.Order order;
@XmlAttribute(name = "encodingStyle", namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
@XmlSchemaType(name = "anyURI")
protected String encodingStyle;
//-----------------------
}
的問題是,我很得到soResponse總是空的!!?
您究竟如何解組XML? 'soResponse'在你的例子中不是根元素(但是'Envelope')。簡單的解組不起作用。 – DRCB
@DRCB在org.springframework.oxm.Unmarshaller –