Este contenido no está disponible en el idioma seleccionado.
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>
<dependency>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-remote</artifactId>
<version> <!-- SY version goes here (e.g. 1.0) --> </version>
</dependency>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
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());
}
}
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());
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.
Hacer que el código abierto sea más inclusivo
Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.
Acerca de Red Hat
Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.