I have generated a Soap webservice client using wsimport and trying to consume the webservice on Websphere 9.0.5.13
- The application classloader is set to parent last
- I added the following JVM argument in websphere: -
Djavax.xml.bind.JAXBContext=com.sun.xml.internal.bind.v2.ContextFactory
When trying to call the webservice, it succeeds in the first call, and all the following calls fail with the exception:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.mycompany.com", local:"MyOCRFileRequestRs"). Expected elements are (none)] My code is as follows:
private MyOCRFileRequestRsType callMyOCRService(MyOCRFileRequestRqType MyOCRRequest) throws Exception { String headerValue = "Bearer "+MyTokenClient.getToken(); MyOCRFileRequest port= esbOcrSerice.getMyOCRFileRequestSOAP11(); Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,ConfigManager.getMyOCRRequestUrl().split("[?]")[0]); requestContext.put("javax.xml.ws.http.request.headers", Collections.singletonMap("Authorization", Collections.singletonList(headerValue))); try { return port.MyOCRFileRequest(MyOCRRequest); } catch (Exception e) { throw e; } } The first call works fine with no issues, but all the subsequent calls fails with the following error:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.mycompany.com", local:"MyOCRFileRequestRs"). Expected elements are (none)] MyOCRFileRequest interface:
@WebService(name = "MyOCRFileRequest", targetNamespace = "http://www.mycompany.com") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) @XmlSeeAlso({ ObjectFactory.class }) public interface MyOCRFileRequest { /** * * @param MyOCRFileRequestRq * @return * returns com.mycompany.idrak.MyOCRFileRequestRsType */ @WebMethod(operationName = "MyOCRFileRequest", action = "MyOCRFileRequest") @WebResult(name = "MyOCRFileRequestRs", targetNamespace = "http://www.mycompany.com", partName = "MyOCRFileRequestRs") public MyOCRFileRequestRsType MyOCRFileRequest( @WebParam(name = "MyOCRFileRequestRq", targetNamespace = "http://www.mycompany.com", partName = "MyOCRFileRequestRq") MyOCRFileRequestRqType MyOCRFileRequestRq); } MyOCRFileRequestRsType:
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "MyOCRFileRequestRs_Type", propOrder = { "msgRsHdr", "body" }) public class MyOCRFileRequestRsType { @XmlElement(name = "MsgRsHdr", required = true) protected MsgRsHdrType msgRsHdr; @XmlElement(name = "Body") protected MyOCRFileRequestRsBodyType body; public MsgRsHdrType getMsgRsHdr() { return msgRsHdr; } public void setMsgRsHdr(MsgRsHdrType value) { this.msgRsHdr = value; } public MyOCRFileRequestRsBodyType getBody() { return body; } public void setBody(MyOCRFileRequestRsBodyType value) { this.body = value; } } UPDATES:
I tried using the JVM custom property, and issue still exist
com.ibm.xml.xlxp.jaxb.opti.level=0 Is there's any configuration I need to change in Websphere in order to fix that ?
@XmlRootElementannotation.