Search in sources :

Example 6 with ServiceInterfaceStrategy

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

the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithRequestWrapperAndClient.

@Test
public void testServiceInterfaceStrategyWithRequestWrapperAndClient() {
    ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(com.example.customerservice2.CustomerService.class, true);
    QName elName = strategy.findQNameForSoapActionOrType("", com.example.customerservice2.GetCustomersByName.class);
    assertEquals("http://customerservice2.example.com/", elName.getNamespaceURI());
    assertEquals("getCustomersByName", elName.getLocalPart());
    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 7 with ServiceInterfaceStrategy

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

the class SoapJaxbDataFormat method unmarshal.

/**
     * Unmarshal a given SOAP xml stream and return the content of the SOAP body
     * @throws IOException,SAXException
     */
public Object unmarshal(Exchange exchange, InputStream stream) throws IOException, SAXException {
    checkElementNameStrategy(exchange);
    String soapAction = getSoapActionFromExchange(exchange);
    // Determine the method name for an eventual BeanProcessor in the route
    if (soapAction != null && elementNameStrategy instanceof ServiceInterfaceStrategy) {
        ServiceInterfaceStrategy strategy = (ServiceInterfaceStrategy) elementNameStrategy;
        String methodName = strategy.getMethodForSoapAction(soapAction);
        exchange.getOut().setHeader(Exchange.BEAN_METHOD_NAME, methodName);
    }
    // This is necessary as the soap action in the message may get lost on the way
    if (soapAction != null) {
        exchange.setProperty(Exchange.SOAP_ACTION, soapAction);
    }
    Object unmarshalledObject = super.unmarshal(exchange, stream);
    Object rootObject = JAXBIntrospector.getValue(unmarshalledObject);
    return adapter.doUnmarshal(exchange, stream, rootObject);
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy)

Example 8 with ServiceInterfaceStrategy

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

the class MultiPartClientMarshalTest method createRouteBuilder.

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

        @Override
        public void configure() throws Exception {
            ServiceInterfaceStrategy strat = new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
            SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
            from("direct:start").marshal(soapDataFormat).log("marshal to: ${body}").end();
        }
    };
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 9 with ServiceInterfaceStrategy

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

the class MultiPartCxfServerTest method configure.

@Override
public void configure() throws Exception {
    ServiceInterfaceStrategy strat = new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
    SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
    from("direct:start").marshal(soapDataFormat).log("marshal to: ${body}").to("direct:cxfEndpoint").unmarshal(soapDataFormat).end();
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy)

Example 10 with ServiceInterfaceStrategy

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

the class ServiceInterfaceStrategyTest method testMultiPart.

@Test
public void testMultiPart() {
    ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(MultiPartCustomerService.class, true);
    QName custNameQName = strategy.findQNameForSoapActionOrType("http://multipart.customerservice.example.com/getCustomersByName", com.example.customerservice.multipart.GetCustomersByName.class);
    QName custTypeQName = strategy.findQNameForSoapActionOrType("http://multipart.customerservice.example.com/getCustomersByName", com.example.customerservice.multipart.Product.class);
    assertEquals("http://multipart.customerservice.example.com/", custNameQName.getNamespaceURI());
    assertEquals("getCustomersByName", custNameQName.getLocalPart());
    assertEquals("http://multipart.customerservice.example.com/", custTypeQName.getNamespaceURI());
    assertEquals("product", custTypeQName.getLocalPart());
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) QName(javax.xml.namespace.QName) 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