/** * Gets the full-form httpinvoker label from the case-insensitive short-name. * @param name the case-insensitive short-name * @return the full-form httpinvoker label */ public static final String toLabel(String name) { HttpInvokerLabel label = ofName(name); return label != null ? label.label() : null; }
/** * Prints all known httpinvoker labels. * @param args ignored */ public static void main(String... args) { Label.Util.print(values()); } }
private HttpInvokerLabel() { _label = Label.Util.toSwitchYardLabel("httpinvoker", name()); }
@Test public void testDeployment() throws Exception { // Create a new remote client invoker String port = System.getProperty("org.switchyard.component.sca.client.port", "8080"); RemoteInvoker invoker = new HttpInvoker("http://localhost:" + port + "/switchyard-remote"); // Create the request message RemoteMessage message = new RemoteMessage(); message.setService(SERVICE).setOperation("acceptMessage").setContent("test"); // Invoke the service invoker.invoke(message); }
prop.addLabels(HttpInvokerLabel.HEADER.label());
@Override public RemoteMessage invoke(RemoteMessage request) throws IOException { RemoteEndpoint ep = _loadBalancer.selectEndpoint(request.getService()); if (ep == null) { throw RemoteMessages.MESSAGES.noRemoteEndpointFound(request.getService().toString()); } return new HttpInvoker(ep.getEndpoint()).invoke(request); }
try { RemoteInvoker invoker = new HttpInvoker(urls.get(i));
conn.setDoOutput(true); conn.addRequestProperty(SERVICE_HEADER, request.getService().toString()); for (Property prop : request.getContext().getProperties(HttpInvokerLabel.HEADER.label())) { conn.addRequestProperty(prop.getName(), prop.getValue().toString());
@Test public void testDeployment() throws Exception { RemoteInvoker invoker = new HttpInvoker(URL); // Create request payload Order order = new Order(); order.setItem("Turkey"); order.setQuantity(1); // Create the request message RemoteMessage message = new RemoteMessage(); message.setService(SERVICE).setOperation("submitOrder").setContent(order); // Invoke the service RemoteMessage reply = invoker.invoke(message); System.out.println(">>>>> " + reply.getContent().toString()); OrderAck orderAck = (OrderAck) reply.getContent(); Assert.assertEquals(true, orderAck.isAccepted()); Assert.assertEquals("Order Accepted", orderAck.getStatusDescription()); Assert.assertEquals("PO-19838-XYZ", orderAck.getOrderId()); }
.addLabels(BehaviorLabel.TRANSIENT.label(), HttpInvokerLabel.HEADER.label());
@Test public void testDeployment() throws Exception { String port = System.getProperty("org.switchyard.component.sca.client.port", "8080"); RemoteInvoker invoker = new HttpInvoker("http://localhost:" + port + "/switchyard-remote"); // Create request payload Order order = new Order(); order.setItemId("Turkey"); order.setOrderId("Xmas Dinner"); order.setQuantity(1); // Create the request message RemoteMessage message = new RemoteMessage(); message.setService(SERVICE).setOperation("submitOrder").setContent(order); // Invoke the service RemoteMessage reply = invoker.invoke(message); Assert.assertFalse(reply.isFault()); OrderAck orderAck = (OrderAck) reply.getContent(); Assert.assertTrue(orderAck.isAccepted()); }
.addLabels(BehaviorLabel.TRANSIENT.label(), HttpInvokerLabel.HEADER.label());
@Test public void testOffer() throws Exception { RemoteInvoker invoker = new HttpInvoker(URL); Application app = new Application(); app.setName("Magesh"); app.setCreditScore(812); Car car = new Car(); car.setPrice(9600); Offer offer = new Offer(); offer.setApplication(app); offer.setCar(car); offer.setAmount(9000); RemoteMessage message = new RemoteMessage(); message.setService(SERVICE) .setOperation("offer") .setContent(offer); // Invoke the service RemoteMessage reply = invoker.invoke(message); Deal deal = (Deal)reply.getContent(); Assert.assertTrue(deal.isAccepted()); } }