Search in sources :

Example 6 with Person

use of org.apache.camel.wsdl_first.Person in project camel by apache.

the class CXFWsdlOnlyTest method testRoutesWithFault.

@Test
public void testRoutesWithFault() throws Exception {
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first", "PersonService"));
    Person client = ss.getSoap();
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port3 + "/CXFWsdlOnlyTest/PersonService/");
    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);
    personId.value = "";
    ssn = new Holder<String>();
    name = new Holder<String>();
    Throwable t = null;
    try {
        client.getPerson(personId, ssn, name);
        fail("Expect exception");
    } catch (UnknownPersonFault e) {
        t = e;
    }
    assertTrue(t instanceof UnknownPersonFault);
    Person client2 = ss.getSoap2();
    ((BindingProvider) client2).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port4 + "/CXFWsdlOnlyTest/PersonService/");
    Holder<String> personId2 = new Holder<String>();
    personId2.value = "hello";
    Holder<String> ssn2 = new Holder<String>();
    Holder<String> name2 = new Holder<String>();
    client2.getPerson(personId2, ssn2, name2);
    assertEquals("Bonjour", name2.value);
    personId2.value = "";
    ssn2 = new Holder<String>();
    name2 = new Holder<String>();
    try {
        client2.getPerson(personId2, ssn2, name2);
        fail("Expect exception");
    } catch (UnknownPersonFault e) {
        t = e;
    }
    assertTrue(t instanceof UnknownPersonFault);
}
Also used : UnknownPersonFault(org.apache.camel.wsdl_first.UnknownPersonFault) QName(javax.xml.namespace.QName) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) Test(org.junit.Test)

Example 7 with Person

use of org.apache.camel.wsdl_first.Person in project camel by apache.

the class CamelDestinationTest method testCAMEL4073.

@Test
public void testCAMEL4073() throws Exception {
    try {
        Endpoint.publish("camel://foo", new Person() {

            public void getPerson(Holder<String> personId, Holder<String> ssn, Holder<String> name) throws UnknownPersonFault {
            }
        });
        fail("Should throw and Exception");
    } catch (WebServiceException ex) {
        Throwable c = ex.getCause();
        assertNotNull(c);
        assertTrue(c instanceof NoSuchEndpointException);
    }
}
Also used : UnknownPersonFault(org.apache.camel.wsdl_first.UnknownPersonFault) WebServiceException(javax.xml.ws.WebServiceException) Person(org.apache.camel.wsdl_first.Person) NoSuchEndpointException(org.apache.camel.NoSuchEndpointException) Test(org.junit.Test)

Example 8 with Person

use of org.apache.camel.wsdl_first.Person in project camel by apache.

the class CxfBeanTest method testJaxWsBeanFromCxfRoute.

@Test
public void testJaxWsBeanFromCxfRoute() throws Exception {
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first", "PersonService"));
    Person client = ss.getSoap();
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort1() + "/CxfBeanTest/PersonService/");
    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("Get a wrong personId", "hello", personId.value);
    assertEquals("Get a wrong SSN", "000-000-0000", ssn.value);
    assertEquals("Get a wrong name", "Bonjour", name.value);
}
Also used : QName(javax.xml.namespace.QName) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Person (org.apache.camel.wsdl_first.Person)8 Test (org.junit.Test)8 URL (java.net.URL)7 Holder (javax.xml.ws.Holder)7 PersonService (org.apache.camel.wsdl_first.PersonService)7 UnknownPersonFault (org.apache.camel.wsdl_first.UnknownPersonFault)5 Client (org.apache.cxf.endpoint.Client)4 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)4 QName (javax.xml.namespace.QName)3 WebServiceException (javax.xml.ws.WebServiceException)2 SOAPFault (javax.xml.soap.SOAPFault)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)1 JaxwsTestHandler (org.apache.camel.wsdl_first.JaxwsTestHandler)1