<dependency> <groupId>org.switchyard</groupId> <artifactId>switchyard-remote</artifactId> <version> <!-- SY version goes here (e.g. 0.8.0.Final) --> </version> </dependency>
The RemoteInvoker serves as a remote invocation client for SwitchYard services. It allows non-SwitchYard applications to invoke any service in SwitchYard which uses a <binding.sca> binding. It is also used by the internal clustering channel to facilitate intra-cluster communication between instances.
RemoteInvoker and supporting classes can be included in your application via the following Maven dependency:
<dependency> <groupId>org.switchyard</groupId> <artifactId>switchyard-remote</artifactId> <version> <!-- SY version goes here (e.g. 0.8.0.Final) --> </version> </dependency>
Each instance of SY includes a special context path called "switchyard-remote" which is bound to the default HTTP listener in AS 7. The initial version of RemoteInvoker supports communication with this endpoint directly. Here's an example of invoking an in-out service in SY 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()); } }
The remote-invoker quickstart serves as a nice example of using RemoteInvoker with a SwitchYard application.