2017-10-11 52 views
0

我試着通過發送存根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) 

的方式IM執行,這是

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; 

} 

感謝

回答

0

Java doc說,大約@XmlSeeAlso -

指示JAXB在綁定此類時也綁定其他類。

您使用了帶有Test.class值的批註@XmlSeeAlso,它不正確。它應該在綁定Test類時需要綁定的其他類。

+0

感謝reply.I從那裏刪除註釋。測試類綁定到生成的類(存根類)的Element類。 – Dilantha

相關問題