Search in sources :

Example 1 with ServiceInterfaceStrategy

use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.

the class SoapClientTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        String jaxbPackage = GetCustomersByName.class.getPackage().getName();

        @Override
        public void configure() throws Exception {
            ElementNameStrategy elNameStrat = new ServiceInterfaceStrategy(CustomerService.class, true);
            SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat(jaxbPackage, elNameStrat);
            final InputStream in = this.getClass().getResourceAsStream("response.xml");
            from("direct:start").marshal(soapDataFormat).process(new FileReplyProcessor(in)).unmarshal(soapDataFormat);
        }
    };
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) ElementNameStrategy(org.apache.camel.dataformat.soap.name.ElementNameStrategy) RouteBuilder(org.apache.camel.builder.RouteBuilder) InputStream(java.io.InputStream)

Example 2 with ServiceInterfaceStrategy

use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.

the class SoapCxfClientTest method configure.

public void configure() throws Exception {
    String jaxbPackage = GetCustomersByName.class.getPackage().getName();
    ElementNameStrategy elNameStrat = new ServiceInterfaceStrategy(CustomerService.class, false);
    SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat(jaxbPackage, elNameStrat);
    getContext().setTracing(true);
    //
    from("direct:cxfclient").onException(Exception.class).handled(true).marshal(soapDataFormat).end().unmarshal(//
    soapDataFormat).bean(//
    serverBean).marshal(soapDataFormat);
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) ElementNameStrategy(org.apache.camel.dataformat.soap.name.ElementNameStrategy) GetCustomersByName(com.example.customerservice.GetCustomersByName)

Example 3 with ServiceInterfaceStrategy

use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.

the class SoapCxfServerTest method configure.

public void configure() throws Exception {
    String jaxbPackage = GetCustomersByName.class.getPackage().getName();
    ElementNameStrategy elNameStrat = new ServiceInterfaceStrategy(CustomerService.class, true);
    SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat(jaxbPackage, elNameStrat);
    //
    from("direct:camelClient").marshal(//
    soapDataFormat).to(//
    "direct:cxfEndpoint").unmarshal(soapDataFormat);
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) ElementNameStrategy(org.apache.camel.dataformat.soap.name.ElementNameStrategy) GetCustomersByName(com.example.customerservice.GetCustomersByName)

Example 4 with ServiceInterfaceStrategy

use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.

the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithClient.

@Test
public void testServiceInterfaceStrategyWithClient() {
    ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, true);
    QName elName = strategy.findQNameForSoapActionOrType("", GetCustomersByName.class);
    assertEquals("http://customerservice.example.com/", elName.getNamespaceURI());
    assertEquals("getCustomersByName", elName.getLocalPart());
    QName elName2 = strategy.findQNameForSoapActionOrType("getCustomersByName", GetCustomersByName.class);
    assertEquals("http://customerservice.example.com/", elName2.getNamespaceURI());
    assertEquals("getCustomersByName", elName2.getLocalPart());
    // Tests the case where the soap action is found but the in type is null
    QName elName3 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getAllCustomers", null);
    assertNull(elName3);
    QName elName4 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getAllAmericanCustomers", null);
    assertNull(elName4);
    try {
        elName = strategy.findQNameForSoapActionOrType("test", Class.class);
        fail();
    } catch (RuntimeCamelException e) {
        LOG.debug("Caught expected message: " + e.getMessage());
    }
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) QName(javax.xml.namespace.QName) RuntimeCamelException(org.apache.camel.RuntimeCamelException) Test(org.junit.Test)

Example 5 with ServiceInterfaceStrategy

use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.

the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithServer.

@Test
public void testServiceInterfaceStrategyWithServer() {
    ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, false);
    // Tests the case where the action is not found but the type is
    QName elName = strategy.findQNameForSoapActionOrType("", GetCustomersByNameResponse.class);
    assertEquals("http://customerservice.example.com/", elName.getNamespaceURI());
    assertEquals("getCustomersByNameResponse", elName.getLocalPart());
    // Tests the case where the soap action is found
    QName elName2 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getCustomersByName", GetCustomersByName.class);
    assertEquals("http://customerservice.example.com/", elName2.getNamespaceURI());
    assertEquals("getCustomersByNameResponse", elName2.getLocalPart());
    // found
    try {
        elName = strategy.findQNameForSoapActionOrType("test", Class.class);
        fail();
    } catch (RuntimeCamelException e) {
        LOG.debug("Caught expected message: " + e.getMessage());
    }
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) QName(javax.xml.namespace.QName) RuntimeCamelException(org.apache.camel.RuntimeCamelException) Test(org.junit.Test)

Aggregations

ServiceInterfaceStrategy (org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy)10 QName (javax.xml.namespace.QName)4 Test (org.junit.Test)4 RuntimeCamelException (org.apache.camel.RuntimeCamelException)3 ElementNameStrategy (org.apache.camel.dataformat.soap.name.ElementNameStrategy)3 GetCustomersByName (com.example.customerservice.GetCustomersByName)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 InputStream (java.io.InputStream)1