【发布时间】:2018-07-06 10:22:43
【问题描述】:
我是 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 类型。我尝试添加其他 SO 帖子中提到的默认操作命名空间,但无济于事。我什至不知道它是否与命名空间有关。如果有人能指出我可以尝试解决这个问题的方向,我将不胜感激。
编辑:添加 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>
【问题讨论】:
-
添加整个 WSDL 是可能的。您的响应应该是 ConfirmAStatusResponse 而不是 ConfirmAStatus 这是一个不同的对象。
-
@Namphibian 很遗憾我不能发布整个 wsdl,我可以发布必要的部分
标签: java soap wsdl apache-camel cxf