311.5. 多部分消息
可从 Camel 2.8.1 开始
ServiceInterfaceStrategy 支持多部分 SOAP 信息。ServiceInterfaceStrategy 必须使用一个服务接口定义初始化,该定义会根据 JAX-WS 2.2 进行注解,并符合 Document Bare 风格的要求。目标方法必须满足以下条件,如 JAX-WS 规格:1。如果它具有大多数 在 /out 的非header参数或非header 参数中,则它必须具有最多的非header 参数,2)。如果它具有不得在 返回类型,则它必须具有最多的 / 或 out non-header 参数中的out / 或非header 参数。out
ServiceInterfaceStrategy 应使用布尔值参数进行初始化,该参数指示映射策略应用到请求参数或响应参数。
ServiceInterfaceStrategy strat = new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);311.5.1. 多部分请求
多部分请求的有效负载参数使用可反映目标操作的 BeanInvocation 对象进行 initiazlied。在调用 marshal () 处理器时,camel-soap DataFormat 将 BeanInvocation 中的内容映射到 SOAP 标头中的字段,并根据 JAX-WS 映射进行正文。
BeanInvocation beanInvocation = new BeanInvocation();
// Identify the target method
beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("getCustomersByName",
GetCustomersByName.class, com.example.customerservice.multipart.Product.class));
// Populate the method arguments
GetCustomersByName getCustomersByName = new GetCustomersByName();
getCustomersByName.setName("Dr. Multipart");
Product product = new Product();
product.setName("Multiuse Product");
product.setDescription("Useful for lots of things.");
Object[] args = new Object[] {getCustomersByName, product};
// Add the arguments to the bean invocation
beanInvocation.setArgs(args);
// Set the bean invocation object as the message body
exchange.getIn().setBody(beanInvocation);