我的服务端代码有这样的一段特殊的东西
throw new SoapException("soapException",new SoapFault(123,"hello"));
问题就在这个SoapFault,这个对象里面是这样的。
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "errorCode",
    "msg"
})
@XmlRootElement(name = "ServiceException")
public class SoapFault {    @XmlElement(name = "ErrorCode")
    protected long errorCode;
    @XmlElement(name = "Msg", required = true)
    protected String msg;    public SoapFault(ServiceException serviceException){
     this.errorCode = serviceException.getErrorCode();
     this.msg = serviceException.getMessage();
    }
    
    public SoapFault(long errorCode,String msg){
     this.errorCode = errorCode;
     this.msg = msg;
    }
    /**
     * 获取errorCode属性的值。
     * 
     */
    public long getErrorCode() {
        return errorCode;
    }    /**
     * 设置errorCode属性的值。
     * 
     */
    public void setErrorCode(long value) {
        this.errorCode = value;
    }    /**
     * 获取msg属性的值。
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getMsg() {
        return msg;
    }    /**
     * 设置msg属性的值。
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setMsg(String value) {
        this.msg = value;
    }
    }
我在tomcat发布的时候会报这个错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManagerService': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.interceptor.Fault: Could not find JAXB information for bean class com.centralsoft.framework.core.soa.SoapFault in context.   Make sure it follows JAXB conventions.问题好像就是在于那些出代码外的@XmlType这些东西。求大神解答,很急,在线等。SpringJava

解决方案 »

  1.   

    1.创建userManagerService这个bean的时候也出错了。
    2.@XmlElement这个我记得是放在get方法上的@XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "errorCode",
        "msg"
    })
    @XmlRootElement(name = "ServiceException")
    public class SoapFault {   
        protected long errorCode;
        
        protected String msg;    public SoapFault(ServiceException serviceException){
         this.errorCode = serviceException.getErrorCode();
         this.msg = serviceException.getMessage();
        }
        
        public SoapFault(long errorCode,String msg){
         this.errorCode = errorCode;
         this.msg = msg;
        }
        /**
         * 获取errorCode属性的值。
         * 
         */
     @XmlElement(name = "ErrorCode")
        public long getErrorCode() {
            return errorCode;
        }    /**
         * 设置errorCode属性的值。
         * 
         */
        public void setErrorCode(long value) {
            this.errorCode = value;
        }    /**
         * 获取msg属性的值。
         * 
         * @return
         *     possible object is
         *     {@link String }
         *     
         */
    @XmlElement(name = "Msg", required = true)
        public String getMsg() {
            return msg;
        }    /**
         * 设置msg属性的值。
         * 
         * @param value
         *     allowed object is
         *     {@link String }
         *     
         */
        public void setMsg(String value) {
            this.msg = value;
        }
        }
      

  2.   

    @XmlElement是可以放类属性上的@XmlType的name为什么为空呢
      

  3.   

    一般如果类名是Abc,name就会是abc,不过可能不是必须的,总之不要留空