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

14.2. Use a RemoteInvoker


Procedure 14.1. Task

  • Include a RemoteInvoker and supporting classes in your application with the following Maven dependency:
    <dependency>
       <groupId>org.switchyard</groupId>
       <artifactId>switchyard-remote</artifactId>
       <version> <!-- SY version goes here (e.g. 1.0) --> </version>
    </dependency>
    
Each instance of SwitchYard includes a special context path called switchyard-remote, which is bound to the default HTTP listener in Red Hat JBoss Fuse. The initial version of RemoteInvoker supports communication with this endpoint directly. Here is an example of invoking an in-out service in SwitchYard using the HttpInvoker:
public class MyClient {
    public static void main(String[] args) throws Exception {
        RemoteInvoker invoker = new HttpInvoker("http://localhost:8080/switchyard-remote");
        Offer offer = new Offer();
        offer.setAmount(100);
        offer.setItem("honda");
        
        RemoteMessage msg = invoker.invoke(new RemoteMessage()
            .setContext(new DefaultContext())
            .setService(new QName("urn:com.example.switchyard:remote", "Dealer"))
            .setContent(offer));
        
        Deal deal = (Deal)msg.getContent();
        System.out.println("It's a deal? " + deal.isAccepted());
    }
}
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.