Search in sources :

Example 6 with PersonService

use of org.apache.camel.wsdl_first.PersonService 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 PersonService

use of org.apache.camel.wsdl_first.PersonService 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

URL (java.net.URL)7 Holder (javax.xml.ws.Holder)7 Person (org.apache.camel.wsdl_first.Person)7 PersonService (org.apache.camel.wsdl_first.PersonService)7 Test (org.junit.Test)7 UnknownPersonFault (org.apache.camel.wsdl_first.UnknownPersonFault)4 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 SOAPFault (javax.xml.soap.SOAPFault)1 WebServiceException (javax.xml.ws.WebServiceException)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 JaxwsTestHandler (org.apache.camel.wsdl_first.JaxwsTestHandler)1