在jaxb中,这个上下文中也没有任何超类

时间:2017-10-11 16:17:46

标签: java web-services soap jaxb

尝试通过存根发送肥皂请求时,我会遇到异常。

    [com.sun.istack.internal.SAXException2: class com.domain.Test nor any of its super class is known to this context.
    javax.xml.bind.JAXBException: class com.domain.Test nor any of its super class is known to this context.]
at com.sun.xml.internal.ws.message.jaxb.JAXBMessage.writePayloadTo(JAXBMessage.java:408)
    at com.sun.xml.internal.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:173)
    at com.sun.xml.internal.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:206)
    at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:129)
    at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:227)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:210)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:130)
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:95)

我执行此操作的方式是

NmsRtEvent event = new NmsRtEvent(); // WebServiceClient
RtEventMethodsSoap methodsSoap = event.getRtEventMethodsSoap(); //WebService
Element element = new Element();
element.setAny(new Test());
plId = methodsSoap.pushEvent(token,element);

测试课

@XmlType(namespace = "http://www.test.com/test")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Test implements Serializable{

    private int id;

}

由于

1 个答案:

答案 0 :(得分:0)

Java doc说@XmlSeeAlso -

  

指示JAXB在绑定此类时也绑定其他类。

你使用注释@XmlSeeAlso和Test.class值,它不正确。在绑定Test类时,它应该是需要绑定的其他类。