Search code examples
apache-camelosgiapache-httpclient-4.xapache-servicemix

How to use Apache httpclient-win in a Camel route within an OSGi container?


I'm trying to use Apache httpclient-win to get at IIS-hosted Web resources secured by Windows Authentication. I've managed to use the Camel HTTP4 component without authentication. I've also managed to use httpclient-win with authentication successfully from straight Java code. But now, I'm having a hard time figuring out how to use httpclient-win in a Camel route hosted in an OSGi container (ServiceMix).


Solution

  • I managed to create an OSGi bundle that embeds the dependencies required by httpclient-win by adding this section to my POM file:

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.7</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>BundleName</Bundle-SymbolicName>
                        <Embed-Dependency>httpclient|httpcore|httpclient-win|jna|jna-platform;scope=compile|runtime|provided</Embed-Dependency>
                        <Embed-Transitive>true</Embed-Transitive>
                    </instructions>
                </configuration>
            </plugin>