Expand my Community achievements bar.

SOLVED

Cannot use httpclient-osgi in AEM

Avatar

Level 2

Hi,

  I'm trying to use the httpclient-osgi in an osgi bundle to act as a SOAP client, and I'm getting an issue at run-time.

My OSGi bundle is failing to start as its "Unable to resolve [302.23] : missing requirement : [302.23] : osgi.wiring.package; (osgi.wiring.package=com.ibm.uvm.tools)

I think this means that the bundle dependencies of httpclient-osgi mean it is trying to find the code for 'com.ibm.uvm.tools', but it's unable resolve it.

I've amended my Maven pom file to also <Import-Package>com.ibm.uvm.tools.*,*</Import-Package>, to try and include the code, but it didn't have any effect.

Any ideas?

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 2

I may have a few pointers for you:

 

In HttpClient, this is how I set the Proxy Password:

        Client client = ClientProxy.getClient(cxfProxy);
        HTTPConduit http = (HTTPConduit) client.getConduit();
        if(httpClientPolicy== null){
            httpClientPolicy= new HTTPClientPolicy();
        }
        httpClientPolicy.setProxyServer(httpProxySettings.proxyHost);
        httpClientPolicy.setProxyServerPort(httpProxySettings.proxyPort);
        ProxyAuthorizationPolicy authPolicy = new ProxyAuthorizationPolicy();
        authPolicy.setUserName(httpProxySettings.proxyUser);
        authPolicy.setPassword(httpProxySettings.proxyPassword);
        http.setProxyAuthorization(authPolicy);
        http.setClient(httpClientPolicy);

--> this also works with the CXF (and I believe also JAX-WS) web service clients when done in the right place.

 

I don't have the pom with me right now, but this is a very straight forward dependency to the httpclient dependencies. Version 3 and 4 are quite different, so make sure your code is correct for the version you're using:

Version 3:

http://mvnrepository.com/artifact/commons-httpclient/commons-httpclient

Version 4:

http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient

View solution in original post

4 Replies

Avatar

Level 2

hi Stephen,

I am using httpclient by adding a simple dependency to my pom files to the "commons-httpclient" artefact. This allows me to use the apache httpclient libs from CQ without any dependency issues.

If your main goal is to consume SOAP Web Services, maybe our two blog posts can help:

http://cqblog.inside-solutions.ch/2013/11/01/consuming-soap-web-service-with-jax-ws-in-cq5-6-1/

http://cqblog.inside-solutions.ch/2013/09/04/consuming-webservices-using-apache-cxf-in-cq5-6-1/

cheers,

Ben

Avatar

Level 2

Hi Ben

 Thanks for the reply. Reason I'm using (or trying to!) httpclient is because I was having problems with the auto-generated soap-client classes, so I though I would construct the http requests myself.

I've already got commons in my pom file, and was wanting to swap to httpclient because of our company proxy being in the way.

Have you got an example of the changes you made to your pom file?

Thanks

Avatar

Level 2

Hi,

 To add, I'm including a dependancy on httpclient-osgi

 

Cheers

Avatar

Correct answer by
Level 2

I may have a few pointers for you:

 

In HttpClient, this is how I set the Proxy Password:

        Client client = ClientProxy.getClient(cxfProxy);
        HTTPConduit http = (HTTPConduit) client.getConduit();
        if(httpClientPolicy== null){
            httpClientPolicy= new HTTPClientPolicy();
        }
        httpClientPolicy.setProxyServer(httpProxySettings.proxyHost);
        httpClientPolicy.setProxyServerPort(httpProxySettings.proxyPort);
        ProxyAuthorizationPolicy authPolicy = new ProxyAuthorizationPolicy();
        authPolicy.setUserName(httpProxySettings.proxyUser);
        authPolicy.setPassword(httpProxySettings.proxyPassword);
        http.setProxyAuthorization(authPolicy);
        http.setClient(httpClientPolicy);

--> this also works with the CXF (and I believe also JAX-WS) web service clients when done in the right place.

 

I don't have the pom with me right now, but this is a very straight forward dependency to the httpclient dependencies. Version 3 and 4 are quite different, so make sure your code is correct for the version you're using:

Version 3:

http://mvnrepository.com/artifact/commons-httpclient/commons-httpclient

Version 4:

http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient