我们已使用 Websphere(8.5.5 service pack 13)和默认 Axis2 实现从 JAX-RPC 迁移到 JAX-WS 服务。所有服务都运行良好,但 1 个客户端在执行相同操作时出现奇怪的错误,而这些操作对于其他服务运行良好。我们启用了 SOAP 日志并使用 SOAPUI 尝试了相同的请求,效果很好。下面是堆栈跟踪。 GetTransactionsV1R8RequestType
未扩展 GetTransactionsRequestType
。
Caused by: javax.xml.ws.WebServiceException: An internal error occurred during JAX-WS marshalling. An object of type com.kk.v1.GetTransactionsV1R8RequestType cannot be converted into the destination type of com.kk.v1.GetTransactionsRequestType
at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:173)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:118)
at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createRequestSignatureArgs(MethodMarshallerUtils.java:482)
at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitBareMethodMarshaller.demarshalRequest(DocLitBareMethodMarshaller.java:192)
at org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.createRequestParameters(JavaBeanDispatcher.java:322)
at org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.invoke(JavaBeanDispatcher.java:102)
at org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:111)
at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:161)
最佳答案
经过一番努力,我找到了根本原因。在此场景中,客户端使用原始 SOAP XML
通过 HTTP
调用我们的 API。 XML 的请求名称为 GetTransactionsV1R8RequestType
,并且请求已成功针对 XSD/架构进行验证。在 HTTP
连接中,客户端将 SOAPAction
属性设置为“getTransactions”,这是 API 的初始版本。请求名称为 XML
为 getTransactionsV1R8RequestType
,预期 SOAP 操作为“getTransactionsV1R8”。
设置正确的 SOAPAction
值解决了问题。
另一个观察结果是,GetTransactionsV1R8RequestType
并未扩展 GetTransactionsRequestType
,而是扩展了 GetTransactionsV1R5RequestType
,并且如果我们设置 SOAPAction
值作为 'getTransactionsV1R5
' 与 SOAP XML
GetTransactionsV1R8RequestType
,它被成功调用操作 'getTransactionsV1R5
' 作为 GetTransactionsV1R8RequestType
可以转换为 GetTransactionsV1R5RequestType
。
关于java - JAX-WS 编码错误。 SomeClassV1R5 无法转换为 SomeClass 的目标类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61979184/