Simples Assim

Posts Tagged ‘Apache ServiceMix

Bug in Apache ServiceMix 4.1.0

with one comment

Written by Fernando Ribeiro

March 28, 2010 at 8:30 pm

Posted in Software

Tagged with ,

Customizing the Import-Package Header in Apache Felix Maven Plugin

leave a comment »

You can replace it, but not append to it.

<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <Import-Package>br.eti.fernandoribeiro</Import-Package>
    </instructions>
  </configuration>
</plugin>

Thanks to Igor for the original post.

Written by Fernando Ribeiro

January 25, 2010 at 4:20 pm

Custom SOAP Faults with servicemix-http on Progress FUSE ESB 4.1.0.3

leave a comment »

It can’t be realized without custom processors because although several expression languages can retrieve the exception message, neither the XQuery or XSLT components work with fault messages.

WSDL

<wsdl:definitions targetNamespace="http://www.fernandoribeiro.eti.br/ws/sample"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.fernandoribeiro.eti.br/ws/sample">
    <wsdl:types>
        <xs:schema elementFormDefault="qualified" targetNamespace="http://www.fernandoribeiro.eti.br/ws/sample">
            ...
            <xs:element name="SampleFault"> <!-- great opportunity for a common type -->
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="Message" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>
    ...
    <wsdl:message name="SampleFault">
        <wsdl:part name="SampleFault" element="tns:SampleFault" />
    </wsdl:message>
    <wsdl:portType name="SamplePortType">
        <wsdl:operation name="SampleOperation">
            ...
            <wsdl:fault name="SampleFault" message="tns:SampleFault" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SampleSoapBinding" type="tns:SamplePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        ...
        <wsdl:operation name="SampleOperation">
            <soap:operation ... />
            ...
            <wsdl:fault name="SampleFault">
                <soap:fault name="SampleFault" use="literal" />
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SampleService">
        <wsdl:port name="SamplePort" binding="tns:SampleSoapBinding">
            <soap:address location="http://ws.fernandoribeiro.eti.br/SampleService/" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

RouteBuilder

package br.eti.fernandoribeiro.ws.sample;

import org.apache.camel.builder.RouteBuilder;

public final class SampleRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        errorHandler(loggingErrorHandler(SampleRouteBuilder.class.getName())); // unnecessary in Apache Camel 2.0

        onException(Exception.class).process(new SampleFaultProcessor());

        ...
    }

}

Processor

package br.eti.fernandoribeiro.ws.sample;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public final class SampleFaultProcessor implements Processor {
    private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance();

    private DocumentBuilder builder;

    public SampleFaultProcessor() throws ParserConfigurationException {
        builder = FACTORY.newDocumentBuilder();
    }

    public void process(final Exchange exch) throws ParserConfigurationException {
        final Document doc = builder.newDocument();

        final Element root = doc.createElementNS("http://www.fernandoribeiro.eti.br/ws/sample", "SampleFault");

        final Element msg = doc.createElementNS("http://www.fernandoribeiro.eti.br/ws/sample", "Message");

        msg.setTextContent(exch.getException().getMessage());

        root.appendChild(msg);

        doc.appendChild(root);

        exch.getFault().setBody(doc);
    }

}

SOAP Reply

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring/>
         <detail>
            <SampleFault xmlns="http://www.fernandoribeiro.eti.br/ws/sample">
               <Message>Sample Message</Message>
            </SampleFault>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

http://fernandoribeiro.eti.br/2009/07/18/error-handling-in-progress-fuse-esb-4-1/

Written by Fernando Ribeiro

December 21, 2009 at 12:36 am

Improvement to servicemix-http 2009.01

with one comment

The Retrieving schema at <Schema Location> message shouldn’t be displayed.

https://issues.apache.org/activemq/browse/SMXCOMP-691 (vote for it!)

Written by Fernando Ribeiro

December 20, 2009 at 6:27 pm

Posted in Software

Tagged with ,

Bug in Maven 2 JBI Plugin 4.1

leave a comment »

Fixed in 4.2.

https://issues.apache.org/activemq/browse/SM-1873

I’m waiting for it to add OSGi bundle manifests to SAs.

Written by Fernando Ribeiro

December 16, 2009 at 8:34 am

Mailing Lists To Subscribe To

leave a comment »

Written by Fernando Ribeiro

November 18, 2009 at 12:24 am

Issue with Apache Felix Bundle Plugin 2.0.0 and m2eclipse 0.9.9

with one comment

Written by Fernando Ribeiro

September 15, 2009 at 9:59 am

How to Change the Maximum Number of Redeliveries in Apache Camel 1.6.0

leave a comment »

errorHandler(deadLetterChannel().maximumRedeliveries(); // default is 5

http://camel.apache.org/dead-letter-channel.html

http://enterpriseintegrationpatterns.com/DeadLetterChannel.html

Written by Fernando Ribeiro

July 18, 2009 at 4:44 pm

Error Handling in Apache Camel 1.6.0

leave a comment »

The default error handler is DeadLetterChannel, but you may want to change it to LoggingErrorHandler, at least:

errorHandler(loggingErrorHandler(SampleRouteBuilder.class.getName()));

The next major version is most certainly going to use the DefaultErrorHandler in Apache Camel 2.0-M2.

http://camel.apache.org/dead-letter-channel.html

http://camel.apache.org/defaulterrorhandler.html

You might also use exception clauses.

Written by Fernando Ribeiro

July 18, 2009 at 4:19 pm

Issue in Progress FUSE ESB 4.0

leave a comment »

If you get a java.lang.NoClassDefFoundError for org.apache.camel.processor.aggregate.AggregationStrategy or other Apache Camel classes when deploying servicemix-camel components, you will need to migrate to OSGi components.

http://fusesource.com/forums/thread.jspa?messageID=3622

http://fusesource.com/docs/esb/4.1/migration/index.html?url=http://fusesource.com/docs/esb/4.1/migration/ESBMigrationFMR.html

Thanks to Igor for the help.

Written by Fernando Ribeiro

July 18, 2009 at 2:57 pm

Posted in Software

Tagged with ,