309.4. 多部分消息


可从 Camel 2.8.1 开始

ServiceInterfaceStrategy 支持多部分 SOAP 信息。ServiceInterfaceStrategy 必须使用一个服务接口定义初始化,该定义会根据 JAX-WS 2.2 进行注解,并符合 Document Bare 风格的要求。目标方法必须满足以下条件,如 JAX-WS 规格:1。如果它具有大多数 /out 的非header参数或非header 参数中,则它必须具有最多的非header 参数,2)。如果它具有不得在 / out 或 out non-header 参数中的 返回类型,则它必须具有最多的 / out 或非header 参数。

ServiceInterfaceStrategy 应使用布尔值参数进行初始化,该参数指示映射策略应用到请求参数或响应参数。

ServiceInterfaceStrategy strat =  new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
Copy to Clipboard Toggle word wrap

309.4.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);
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat