在尝试调用必须在SOAP服务器上打开请求的Rest服务时出现此错误。
JAXB编组异常;嵌套异常是javax.xml.bind.MarshalException \ n-带有链接的异常:
\ n [com.sun.istack.internal.SAXException2:类 java.util.LinkedHashMap从超类继承 dans ce contexte。\ njavax.xml.bind.JAXBException:类 java.util.LinkedHashMap从超类继承 dans ce contexte。]
我的配置
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(NAME_PACKAGE);
return marshaller;
}
@Bean
public WebServiceClients wsClient() {
WebServiceClients client = new WebServiceClients();
log.info("uri {} ", URL_WS);
client.setDefaultUri(URL_WS);//url sans ?wsdl a la fin
client.setMarshaller(marshaller());
client.setUnmarshaller(marshaller());
return client;
}
webserviceClient方法
public Object createTroubleTicketResponseType(CreateTroubleTicketRequestType createTroubleTicketRequestType) {
ObjectFactory objectFactory = new ObjectFactory();
CreateTroubleTicketRequestType ticketRequestType = objectFactory.createCreateTroubleTicketRequestType();
ticketRequestType.setCommonComponents(createTroubleTicketRequestType.getCommonComponents());
ticketRequestType.setIssueReferenceDetails(createTroubleTicketRequestType.getIssueReferenceDetails());
ticketRequestType.setRequestType(createTroubleTicketRequestType.getRequestType());
log.info("call createTroubleTicketRequestType {} ", ticketRequestType);
return getWebServiceTemplate().marshalSendAndReceive( new JAXBElement<CreateTroubleTicketRequestType>(new QName(ROOT_NAMESPACE,"CreateTroubleTicketRequest"), CreateTroubleTicketRequestType.class, ticketRequestType), new SoapActionCallback(WsConstant.OPERATION_CreateTroubleTicketRequest));
}
我的休息服务
@PostMapping("createTroubleTicket2")
public ResponseEntity<?> createTroubleTicketResponseTypePost2(@RequestBody CreateTroubleTicketRequestType createTroubleTicketRequestType) {
log.info("call post function createTroubleTicket {} ", createTroubleTicketRequestType.getRequestType().toString());
return ResponseEntity.ok(webServiceClients.createTroubleTicketResponseType(createTroubleTicketRequestType));
}
完整错误
JAXB marshalling exception; nested exception is javax.xml.bind.MarshalException \ n - with linked exception: \ n [com.sun.istack.internal.SAXException2: class java.util.LinkedHashMap nor any of its superclasses is known in this context. \ njavax.xml.bind.JAXBException: class java.util.LinkedHashMap nor any of its superclasses is known in this context.]