jaxb unmarshalling返回null [英] jaxb unmarshalling returns null

查看:157
本文介绍了jaxb unmarshalling返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在解密肥皂消息的响应,如下所示

I'm unmarshalling a response for soap message like the following

<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> 

我正在将jaxb注释绑定为

and i'm binding the jaxb annotation as

    @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总是为空!!?

the problem is, that i'm getting soResponse always null !!?

推荐答案

看起来你的

@XmlElement(namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
protected soResponse;

这将寻找< SOAP-ENV:soResponse> ,而不是< m:soResponse xmlns:m =urn:tec>

这篇关于jaxb unmarshalling返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆