首页 > 解决方案 > JAX-WS 编组错误。SomeClassV1R5 无法转换为 SomeClass 的目标类型

问题描述

我们已经从 JAX-RPC 迁移到带有 Websphere(8.5.5 服务包 13)和默认 Axis2 实现的 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)

标签: javasoapwebspherejax-wsaxis2

解决方案


经过一番挣扎,我能够找到根本原因。SOAP XML在这种情况下,客户端使用 raw over调用我们的 API HTTP。XML 具有请求名称,GetTransactionsV1R8RequestType并且请求已成功针对 XSD/模式进行验证。在HTTP连接中,客户端设置SOAPAction属性值为“getTransactions”,这是 API 的初始版本。请求名称是XML预期getTransactionsV1R8RequestType的 SOAP 操作是“getTransactionsV1R8”。

设置适当的SOAPAction值解决了这个问题。

与此相关的另一个观察结果GetTransactionsV1R8RequestType不是扩展GetTransactionsRequestType而是扩展GetTransactionsV1R5RequestType,如果我们将SOAPAction值设置为 ' getTransactionsV1R5' SOAP XML GetTransactionsV1R8RequestType,它会通过操作 ' ' 成功调用,getTransactionsV1R5因为GetTransactionsV1R8RequestType可以转换为GetTransactionsV1R5RequestType


推荐阅读