gpt4 book ai didi

java - Camel CXF 抛出 Part{example.com} 参数应该是 X 类型而不是 Y 类型

转载 作者:行者123 更新时间:2023-11-30 06:06:31 27 4
gpt4 key购买 nike

我是 SOAP 新手,无法弄清楚问题出在哪里。我看过similar SO post但不幸的是这没有帮助。错误信息是:

WARNING: Interceptor for {http://bbbts/Service}Service#{http://bbbts/Service}ConfirmAStatus has thrown exception, unwinding now
IllegalArgumentException: Part {http://bbbts/Service}parameters should be of type package.ConfirmAStatusResponse, not package.ConfirmAStatus

我在 Camel 中配置了端点,如下所示:

    CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setAddress("http://0.0.0.0:8888/aaans/services/Service");
cxfEndpoint.setWsdlURL("Service.wsdl");
cxfEndpoint.setCamelContext(camelContext);
cxfEndpoint.setBus(bus);
cxfEndpoint.setServiceNameString("bbbts:Service");
cxfEndpoint.setDefaultOperationName("ConfirmAStatus");
cxfEndpoint.setDefaultOperationNamespace("http://bbbts/Service");

try {
cxfEndpoint.setServiceClass("package.Service");
} catch (ClassNotFoundException e1) {
}
cxfEndpoint.setDataFormat(DataFormat.POJO);

我已经通过 cxf-codegen 生成了 Service 类,它看起来像这样:

@WebService(targetNamespace = "http://bbbts/Service", name = "Service")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface Service {

@WebMethod(operationName = "ConfirmAStatus", action = "http://aaans/2012/nsv1/ConfirmARecallStatus")
@Action(input = "http://aaans/2012/nsv1/ConfirmProductBatchRecallStatus", output = "http://aaans/2012/nsv1/ConfirmAStatusResponse")
@WebResult(name = "ConfirmAStatusResponse", targetNamespace = "http://aaans/2012/", partName = "parameters")
public ConfirmAStatusResponse confirmAStatus(
@WebParam(partName = "parameters", name = "ConfirmAStatus", targetNamespace = "http://aaans/2012/")
ConfirmAStatus parameters
);
.... ConfirmBStatusResponse ...

我继承了 WSDL 文件,但没有任何使用 WSDL 文件的经验,因此请让我知道哪些部分会有所帮助。这是wsdl文件中的操作:

<wsdl:operation name="ConfirmAStatus">
<wsdl:input wsaw:Action="http://aaans/2012/nsv1/ConfirmAStatus" message="tns:Service_ConfirmAStatus_InputMessage"/>
<wsdl:output wsaw:Action="http://aaans/2012/nsv1/ConfirmAStatusResponse" message="tns:Service_ConfirmAStatus_OutputMessage"/>
</wsdl:operation>

我对错误消息很不理解。该函数的参数类型显然是ConfirmAStatus 类型,而不是错误消息中声明的...StatusResponse 类型。我尝试添加默认操作 namespace ,如另一篇 SO 帖子中提到的,但无济于事。我什至不知道它是否与 namespace 有关。如果有人能指出我可以尝试解决这个问题的方向,我将非常感激。

编辑:添加 wsdl:message 部分

<wsdl:message name="Service_ConfirmAStatus_InputMessage">
<wsdl:part name="parameters" element="q1:ConfirmAStatus" xmlns:q1="hhttp://aaans/2012/"/>
</wsdl:message>
<wsdl:message name="Service_ConfirmAStatus_OutputMessage">
<wsdl:part name="parameters" element="q2:ConfirmAStatusResponse" xmlns:q2="http://aaans/2012/"/>
</wsdl:message>

最佳答案

错误消息表明参数 parameters 的类型为 ConfirmAStatus,但应为 ConfirmAStatusResponse 类型

由于您的实现需要类型 ConfirmAStatus

ConfirmAStatus parameters

我怀疑 WSDL 中输入消息的定义是错误的,但这部分内容未包含在您的问题中。

您可能有这样的消息定义

<wsdl:message name="Service_ConfirmAStatus_InputMessage">
<wsdl:part name="NameOfTheElement" element="ReferenceToTheSchemaElementThatRepresentsThisMessagePart"/>
</wsdl:message>

在此示例中,ReferenceToTheSchemaElementThatRepresentsThisMessagePart 的 XML 架构定义似乎是 ConfirmAStatus 类型,而不是 ConfirmAStatusResponse

关于java - Camel CXF 抛出 Part{example.com} 参数应该是 X 类型而不是 Y 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51208262/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com