此内容没有您所选择的语言版本。

10.4. Chaining Transformers


JBoss Fuse Service Works 6.0 allows you to chain transformers. Say you have a transformer that transforms from A to B and another that transforms from B to C. If you then have an invocation where the consumer is using type A and the provider is using type C, then the runtime will invoke the A->B and the B->C transformers to achieve A->C.
For example, for a SOAP message, you could define two transformers:
<transform:transform.java from="{http://web.service.com/}GetStatisticsResponse" to="{urn:web.service.com}StatisticsCData" bean="CDataReturn"/>
<transform:transform.jaxb from="{urn:web.service.com}StatisticsCData" to="java:com.sample.model.Statistics" contextPath="com.sample.model"/>
The first transformer transforms the SOAP reply which contains the GetStatisticsResponse element into an intermediate object which is just the content of the return element (CDATA containing the element), implemented in Java as follows:
@Named("CDataReturn")
public class CDataExtractor {

    @Transformer(from = "{http://web.service.com/}GetStatisticsResponse",
                 to = "{urn:web.service.com}StatisticsCData")
    public String transform(Element from) {
        String value = null;
        NodeList nodes = from.getElementsByTagName("return");
        if(nodes.getLength() > 0 ){
            value = nodes.item(0).getChildNodes().item(0).getNodeValue();
        }
        return value;
    }
}
The second transformer then takes care of transforming from the element to the Statistics Java model using JAXB.
JBoss Fuse Service Works 6.0 knows, from the contracts on the reference definitions, that it needs to go from {http://web.service.com/}GetStatisticsResponse to java:com.sample.model.Statistics and will automatically invoke both transformers to make that happen.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.