我有两个肥皂动作的wsdl。因此,我从中生成了Java类,现在有了一个接口:

@WebService(targetNamespace = "...", name = "...")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface RequestsService {

    @WebMethod
    @WebResult(name = "sendErrorReportResponse", targetNamespace = "...", partName = "result")
    public SendErrorReportResponse sendErrorReport(
        @WebParam(partName = "parameters", name = "sendErrorReport", targetNamespace = "...")
        SendErrorReport parameters
    );

    @WebMethod
    @WebResult(name = "bookRequestResponse", targetNamespace = "...", partName = "result")
    public BookRequestResponse bookRequest(
        @WebParam(partName = "parameters", name = "bookRequest", targetNamespace = "...")
        ServiceRequestMessage parameters
    );
}


然后,我为此接口创建了CXF端点:

@Bean
public CxfEndpoint myEndpoint() {
    CxfEndpoint cxfEndpoint = new CxfEndpoint();
    cxfEndpoint.setAddress("...");
    cxfEndpoint.setServiceClass(RequestsService.class);
    cxfEndpoint.setDataFormat(DataFormat.POJO);
    cxfEndpoint.setLoggingFeatureEnabled(true);
    return cxfEndpoint;
}


路线:

public static final String ENDPOINT = "cxf:bean:myEndpoint";

    @Autowired
    private MyProcessor processor;

    @Override
    public void configure() throws Exception {
        from("quartz2://report?cron=0+*+*+*+*+?")
                .process(processor)
                .to(ENDPOINT);
    }


我的问题是,如何指定调用我的一个肥皂动作-sendErrorReport或bookRequest?

压力
当我从wsdl和报告的类中删除sendErrorReport方法时,此代码适用于bookRequest方法。否则,将出现此异常:

Caused by: java.lang.IllegalArgumentException: Part {http://...} parameters should be of type SendErrorReport, not ServiceRequestMessage
    at org.apache.cxf.jaxb.io.DataWriterImpl.checkPart(DataWriterImpl.java:292)
    at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:220)
...

最佳答案

您可以在端点URI中设置操作:

ENDPOINT = "cxf:bean:myEndpoint?defaultOperationName=sendErrorReport"

和/或您可以将operationName Camel标头设置为所需值

.process(processor).setHeader("operationName", constant("sendErrorReport")).to(ENDPOINT);

请注意,在这两种情况下,您的处理器都将需要为用于避免上述异常的操作创建适当参数类型的实例。

10-06 13:38