use of java.net.URL in project camel by apache.
the class CXFWsdlOnlyPayloadModeNoSpringTest method testRoutes.
@Test
public void testRoutes() throws Exception {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port1 + "/" + getClass().getSimpleName() + "/PersonService");
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
Holder<String> personId = new Holder<String>();
personId.value = "hello";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
client.getPerson(personId, ssn, name);
assertEquals("Bonjour", name.value);
}
use of java.net.URL in project camel by apache.
the class CxfConsumerPayloadFaultCauseEnabledTest method testInvokingFromCxfClient.
@Test
public void testInvokingFromCxfClient() throws Exception {
this.getCamelContextService();
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, SERVICE_QNAME);
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
Holder<String> personId = new Holder<String>();
personId.value = "";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
try {
client.getPerson(personId, ssn, name);
fail("SOAPFault expected!");
} catch (Exception e) {
assertTrue(e instanceof SOAPFaultException);
SOAPFault fault = ((SOAPFaultException) e).getFault();
assertEquals("Someone messed up the service. Caused by: Homer", fault.getFaultString());
}
}
use of java.net.URL in project camel by apache.
the class CxfConsumerPayloadFaultTest method testInvokingFromCxfClient.
@Test
public void testInvokingFromCxfClient() throws Exception {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
Holder<String> personId = new Holder<String>();
personId.value = "";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
Throwable t = null;
try {
client.getPerson(personId, ssn, name);
fail("expect UnknownPersonFault");
} catch (UnknownPersonFault e) {
t = e;
assertEquals("Get the wrong fault detail", "", e.getFaultInfo().getPersonId());
}
assertNotNull(t);
assertTrue(t instanceof UnknownPersonFault);
}
use of java.net.URL in project camel by apache.
the class CxfCustomizedExceptionTest method testInvokingServiceFromHTTPURL.
@Test
public void testInvokingServiceFromHTTPURL() throws Exception {
URL url = new URL(routerAddress);
URLConnection urlConnection = url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/xml");
// Send POST data
OutputStream out = urlConnection.getOutputStream();
// copy the message out
InputStream is = this.getClass().getResourceAsStream("SimpleSoapRequest.xml");
IOHelper.copy(is, out);
out.flush();
is.close();
// check the response code
try {
urlConnection.getInputStream();
fail("We except an IOException here");
} catch (IOException exception) {
assertTrue(exception.getMessage().contains("500"));
}
}
use of java.net.URL in project camel by apache.
the class CxfMtomRouterRawModeTest method getPort.
@Override
protected Hello getPort() {
URL wsdl = getClass().getResource("/mtom.wsdl");
assertNotNull("WSDL is null", wsdl);
HelloService service = new HelloService(wsdl, HelloService.SERVICE);
assertNotNull("Service is null ", service);
Hello port = service.getHelloPort();
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port1 + "/CxfMtomRouterRawModeTest/jaxws-mtom/hello");
return port;
}
Aggregations