String address = "http://localhost:9001/providertest";
factory.setAddress(address);
Server server = factory.create();
Endpoint endpoint = server.getEndpoint();
endpoint.getInInterceptors().add(new LoggingInInterceptor());
endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
ServiceInfo service = endpoint.getEndpointInfo().getService();
assertNotNull(service);
client = new DefaultServiceMixClient(jbi);
io = client.createInOutExchange();
io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
//send message to proxy
io.getInMessage().setContent(new StringSource(
"<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+ "<part> "
+ "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+ "ffang"
+ "</requestType></greetMe>"
+ "</part> "
+ "</message>"));
client.sendSync(io);
assertTrue(new SourceTransformer().contentToString(
io.getOutMessage()).indexOf("Hello ffang 3") >= 0);
//test exception handle
io = client.createInOutExchange();
io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
io.getInMessage().setContent(new StringSource(
"<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+ "<part> "
+ "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+ "exception test"
+ "</requestType></greetMe>"
+ "</part> "
+ "</message>"));
client.sendSync(io);
assertTrue(new SourceTransformer().contentToString(
io.getOutMessage()).indexOf("Hello exception test Negative number cant be added!") >= 0);
//test onway
factory = new JaxWsServerFactoryBean();
factory.setServiceClass(Greeter.class);
factory.setServiceBean(new GreeterImpl());
address = "http://localhost:9002/providertest_oneway";
factory.setAddress(address);
server = factory.create();
endpoint = server.getEndpoint();
endpoint.getInInterceptors().add(new LoggingInInterceptor());
endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
service = endpoint.getEndpointInfo().getService();
assertNotNull(service);
io = client.createInOutExchange();
io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));