container.start();
Jsr181Component component = new Jsr181Component();
// Create an xfire endpoint for our pojo order service
Jsr181Endpoint orderEndpoint = new Jsr181Endpoint();
orderEndpoint.setPojo(new OrderServiceImpl());
orderEndpoint.setServiceInterface(OrderService.class.getCanonicalName());
component.setEndpoints(new Jsr181Endpoint[] { orderEndpoint });
container.activateComponent(component, "JSR181Component");
System.out.println(orderEndpoint.getServiceInterface());
System.out.println(orderEndpoint.getInterfaceName());
System.out.println(orderEndpoint.getEndpoint());
// Create interface based proxy
JbiProxyFactoryBean pf = new JbiProxyFactoryBean();
pf.setContainer(container);
pf.setInterfaceName(orderEndpoint.getInterfaceName());
pf.setEndpoint(orderEndpoint.getEndpoint());
pf.setType(OrderService.class);
OrderService orderService = (OrderService) pf.getObject();
// Prepare cart for order request
Cart cart = new Cart();
OrderItem orderItem = new OrderItem();
orderItem.setCount(2);
orderItem.setItem("Book");
cart.getItems().add(orderItem);
// Call the service
OrderConfirmation orderConfirmation = orderService.order(cart);
orderConfirmation = orderService.order(cart);
orderConfirmation = orderService.order(cart);
// Check that we get the expected order confirmation
assertNotNull(orderConfirmation);
cart = orderConfirmation.getCart();
assertNotNull(cart);
assertEquals(1, cart.getItems().size());
orderItem = cart.getItems().get(0);
assertEquals(2, orderItem.getCount());
assertEquals("Book", orderItem.getItem());
// Analyse the WSDL that is generated from the pojo service
Document description = orderEndpoint.getDescription();
SourceTransformer transformer = new SourceTransformer();
System.out.println(transformer.toString(description));
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
reader.setFeature(Constants.FEATURE_VERBOSE, false);
Definition definition = reader.readWSDL(null, description);
Map namespaces = definition.getNamespaces();
String serviceNameSpace = orderEndpoint.getInterfaceName().getNamespaceURI();
String modelNameSpace = "http://model.complex.test";
// The WSDL should import the namespaces for the service and the model
assertTrue("Namespace "+ serviceNameSpace +" present", namespaces.containsValue(serviceNameSpace));
assertTrue("Namespace "+ modelNameSpace+" present", namespaces.containsValue(modelNameSpace));