我有两个肥皂动作的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);
}
我的问题是,如何指定调用我的一个soap操作 - sendErrorReport或bookRequest?
P.S 当我从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)
...
答案 0 :(得分:2)
您可以在端点URI中设置操作:
ENDPOINT = "cxf:bean:myEndpoint?defaultOperationName=sendErrorReport"
和/或您可以将operationName
Camel标头设置为所需的值
.process(processor)
.setHeader("operationName", constant("sendErrorReport"))
.to(ENDPOINT);
请注意,在这两种情况下,您的处理器都需要为用于避免上述异常的操作创建适当参数类型的实例。