use of org.apache.hello_world_soap_http.Greeter in project camel by apache.
the class CamelTransportClientServerTest method testClientInvocation.
@Test
public void testClientInvocation() throws MalformedURLException {
Client client = new Client("http://localhost:" + port + "/GreeterContext/GreeterPort");
Greeter port = client.getProxy();
assertNotNull("The proxy should not be null", port);
String resp = port.sayHi();
assertEquals("Get a wrong response ", "Bonjour from EndpointA", resp);
resp = port.sayHi();
assertEquals("Get a wrong response ", "Bonjour from EndpointB", resp);
resp = port.greetMe("Mike");
assertEquals("Get a wrong response ", "Hello Mike from EndpointA", resp);
resp = port.greetMe("James");
assertEquals("Get a wrong response ", "Hello James from EndpointB", resp);
port.greetMeOneWay(System.getProperty("user.name"));
try {
port.pingMe("hello");
fail("exception expected but none thrown");
} catch (PingMeFault ex) {
assertEquals("Wrong exception message received", "PingMeFault raised by server EndpointB", ex.getMessage());
FaultDetail detail = ex.getFaultInfo();
assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
}
}
use of org.apache.hello_world_soap_http.Greeter in project camel by apache.
the class Client method invoke.
public void invoke() throws Exception {
System.out.println("Acquiring router port ...");
Greeter port = getProxy();
String resp;
System.out.println("Invoking sayHi...");
resp = port.sayHi();
System.out.println("Server responded with: " + resp);
System.out.println();
System.out.println("Invoking greetMe...");
resp = port.greetMe(System.getProperty("user.name"));
System.out.println("Server responded with: " + resp);
System.out.println();
System.out.println("Invoking greetMeOneWay...");
port.greetMeOneWay(System.getProperty("user.name"));
System.out.println("No response from server as method is OneWay");
System.out.println();
try {
System.out.println("Invoking pingMe, expecting exception...");
port.pingMe("hello");
} catch (PingMeFault ex) {
System.out.println("Expected exception: PingMeFault has occurred: " + ex.getMessage());
FaultDetail detail = ex.getFaultInfo();
System.out.println("FaultDetail major:" + detail.getMajor());
System.out.println("FaultDetail minor:" + detail.getMinor());
}
}
use of org.apache.hello_world_soap_http.Greeter in project camel by apache.
the class CxfConsumerWSRMTest method testInvokeGreeter.
@Test
public void testInvokeGreeter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
Bus clientBus = context.getRegistry().lookupByNameAndType("client-bus", Bus.class);
assertNotNull(clientBus);
BusFactory.setThreadDefaultBus(clientBus);
try {
Service service = Service.create(SERVICE_NAME);
service.addPort(PORT_NAME, "http://schemas.xmlsoap.org/soap/", "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerWSRMTest/router");
Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
greeter.greetMeOneWay("test");
} finally {
BusFactory.setThreadDefaultBus(null);
}
assertMockEndpointsSatisfied();
}
use of org.apache.hello_world_soap_http.Greeter in project camel by apache.
the class GreeterClientTest method sendMessageWithUsernameToken.
protected String sendMessageWithUsernameToken(String username, String password, String message) throws Exception {
final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, SERVICE_QNAME);
final Greeter greeter = svc.getPort(PORT_QNAME, Greeter.class);
Client client = ClientProxy.getClient(greeter);
Map<String, Object> props = new HashMap<String, Object>();
props.put("action", "UsernameToken");
props.put("user", username);
// Set the the password type to be plain text,
// so we can keep using the password to authenticate with spring security
props.put("passwordType", "PasswordText");
WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor(props);
client.getOutInterceptors().add(wss4jOut);
((BindingProvider) greeter).getRequestContext().put("password", password);
return greeter.greetMe(message);
}
use of org.apache.hello_world_soap_http.Greeter in project camel by apache.
the class WSAddressingTest method testWSAddressing.
@Test
public void testWSAddressing() throws Exception {
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(getClientAddress());
clientBean.setServiceClass(Greeter.class);
SpringBusFactory bf = new SpringBusFactory();
URL cxfConfig = null;
if (getCxfClientConfig() != null) {
cxfConfig = ClassLoaderUtils.getResource(getCxfClientConfig(), this.getClass());
}
proxyFactory.setBus(bf.createBus(cxfConfig));
Greeter client = (Greeter) proxyFactory.create();
String result = client.greetMe("world!");
assertEquals("Get a wrong response", "Hello world!", result);
}
Aggregations