You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by Vincenzo Turco <vi...@gmail.com> on 2014/09/25 19:06:31 UTC

passing arbitrary org.apache.http.client.HttpClient instance to Olingo Client

Hi all,
I'd like to use Olingo as client to my OData services.
My current application server runtime can provide an HttpClient instance.
I'd like to pass this object to Olingo API so that connection to the OData
endpoint could take place through it.
This would be important because the HttpClient instance already has lots of
authentication properties configured by the application server runtime.
Could anyone please direct me to relevant docs?
Thanks, regards
Vincenzo

-- 


Vincenzo Turco

RE: passing arbitrary org.apache.http.client.HttpClient instance to Olingo Client

Posted by "Amend, Christian" <ch...@sap.com>.
Hi Vincento,

the Olingo V2 implementation can produce client payloads. This payloads can then be used with any HttpClient you might have. What the V2 implementation is missing are the Client convenience methods which are available for V3 and V4. This is because we followed more of a library architecture with V2 where we give a client or server the necessary API methods to construct payloads and leave the request as such for the client developer to decide. 

Have a look at the sample here: http://olingo.apache.org/doc/odata2/tutorials/OlingoV2BasicClientSample.html

This will give you a rough overview about how to implement a client with the V2 library which can be downloaded here: http://olingo.apache.org/doc/odata2/download.html

Best Regards,
Christian

-----Original Message-----
From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org] 
Sent: Dienstag, 30. September 2014 17:32
To: dev@olingo.apache.org
Subject: Re: passing arbitrary org.apache.http.client.HttpClient instance to Olingo Client

On 30/09/2014 17:29, Vincenzo Turco wrote:
> ciao Francesco,
> thanks for your kind help.
> I'm going through the code samples e.g. the OlingoSampleApp, and got it
> working nicely with my remote OData service, in a basic fashion without
> authentication, SSO etc.
> Then I tried to update the code with your suggestion on HttpClientFactory,
> but I guess you are referring to the OData v4 client, while I need to
> consume a v2 service.
> So, not sure if the HttpClientFactory strategy applies also to the v2
> scenario, maybe a different route could be followed to consume v2 services
> with a user-defined HttpClient?

Hi Vincenzo,
you are right: everything I wrote below is about Olingo Java client 4 
(which supports OData v3 and v4, but not v2).

Anyone with Olingo 2 skills out there?

Regards.

> 2014-09-26 9:45 GMT+02:00 Francesco Chicchiriccò <il...@apache.org>:
>
>> On 25/09/2014 19:06, Vincenzo Turco wrote:
>>
>>> Hi all,
>>> I'd like to use Olingo as client to my OData services.
>>> My current application server runtime can provide an HttpClient instance.
>>> I'd like to pass this object to Olingo API so that connection to the OData
>>> endpoint could take place through it.
>>> This would be important because the HttpClient instance already has lots
>>> of
>>> authentication properties configured by the application server runtime.
>>> Could anyone please direct me to relevant docs?
>>>
>> Hi Vincenzo,
>> if you want to provide your own HttpClient instance, you'll need to
>>
>> 1. create your own org.apache.olingo.client.api.http.HttpClientFactory
>> implementation (or just extend org.apache.olingo.client.core.http.
>> AbstractHttpClientFactory)
>>
>> 2. set your client instance to use your own HttpClientFactory and not
>> org.apache.olingo.client.core.http.DefaultHttpClientFactory which is -
>> not surprisingly - the default
>>
>> client.getConfiguration().setHttpClientFactory(yourOwnFactory);
>>
>>
>> There are some client factories provided for common usages - basic
>> authentication, NTLM authentication, OAuth 2.0, proxy - in [1] and
>> more samples of how to customize the HttpClient instances under [2].
>>
>> HTH
>> Regards.
>>
>> [1] https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;
>> a=tree;f=lib/client-core/src/main/java/org/apache/olingo/client/core/http
>> [2] https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;
>> a=tree;f=samples/client/src/main/java/org/apache/olingo/
>> samples/client/core/http

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Re: passing arbitrary org.apache.http.client.HttpClient instance to Olingo Client

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 30/09/2014 17:29, Vincenzo Turco wrote:
> ciao Francesco,
> thanks for your kind help.
> I'm going through the code samples e.g. the OlingoSampleApp, and got it
> working nicely with my remote OData service, in a basic fashion without
> authentication, SSO etc.
> Then I tried to update the code with your suggestion on HttpClientFactory,
> but I guess you are referring to the OData v4 client, while I need to
> consume a v2 service.
> So, not sure if the HttpClientFactory strategy applies also to the v2
> scenario, maybe a different route could be followed to consume v2 services
> with a user-defined HttpClient?

Hi Vincenzo,
you are right: everything I wrote below is about Olingo Java client 4 
(which supports OData v3 and v4, but not v2).

Anyone with Olingo 2 skills out there?

Regards.

> 2014-09-26 9:45 GMT+02:00 Francesco Chicchiriccò <il...@apache.org>:
>
>> On 25/09/2014 19:06, Vincenzo Turco wrote:
>>
>>> Hi all,
>>> I'd like to use Olingo as client to my OData services.
>>> My current application server runtime can provide an HttpClient instance.
>>> I'd like to pass this object to Olingo API so that connection to the OData
>>> endpoint could take place through it.
>>> This would be important because the HttpClient instance already has lots
>>> of
>>> authentication properties configured by the application server runtime.
>>> Could anyone please direct me to relevant docs?
>>>
>> Hi Vincenzo,
>> if you want to provide your own HttpClient instance, you'll need to
>>
>> 1. create your own org.apache.olingo.client.api.http.HttpClientFactory
>> implementation (or just extend org.apache.olingo.client.core.http.
>> AbstractHttpClientFactory)
>>
>> 2. set your client instance to use your own HttpClientFactory and not
>> org.apache.olingo.client.core.http.DefaultHttpClientFactory which is -
>> not surprisingly - the default
>>
>> client.getConfiguration().setHttpClientFactory(yourOwnFactory);
>>
>>
>> There are some client factories provided for common usages - basic
>> authentication, NTLM authentication, OAuth 2.0, proxy - in [1] and
>> more samples of how to customize the HttpClient instances under [2].
>>
>> HTH
>> Regards.
>>
>> [1] https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;
>> a=tree;f=lib/client-core/src/main/java/org/apache/olingo/client/core/http
>> [2] https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;
>> a=tree;f=samples/client/src/main/java/org/apache/olingo/
>> samples/client/core/http

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Re: passing arbitrary org.apache.http.client.HttpClient instance to Olingo Client

Posted by Vincenzo Turco <vi...@gmail.com>.
ciao Francesco,
thanks for your kind help.
I'm going through the code samples e.g. the OlingoSampleApp, and got it
working nicely with my remote OData service, in a basic fashion without
authentication, SSO etc.
Then I tried to update the code with your suggestion on HttpClientFactory,
but I guess you are referring to the OData v4 client, while I need to
consume a v2 service.
So, not sure if the HttpClientFactory strategy applies also to the v2
scenario, maybe a different route could be followed to consume v2 services
with a user-defined HttpClient?
thanks a lot, regards
Vincenzo


2014-09-26 9:45 GMT+02:00 Francesco Chicchiriccò <il...@apache.org>:

> On 25/09/2014 19:06, Vincenzo Turco wrote:
>
>> Hi all,
>> I'd like to use Olingo as client to my OData services.
>> My current application server runtime can provide an HttpClient instance.
>> I'd like to pass this object to Olingo API so that connection to the OData
>> endpoint could take place through it.
>> This would be important because the HttpClient instance already has lots
>> of
>> authentication properties configured by the application server runtime.
>> Could anyone please direct me to relevant docs?
>>
>
> Hi Vincenzo,
> if you want to provide your own HttpClient instance, you'll need to
>
> 1. create your own org.apache.olingo.client.api.http.HttpClientFactory
> implementation (or just extend org.apache.olingo.client.core.http.
> AbstractHttpClientFactory)
>
> 2. set your client instance to use your own HttpClientFactory and not
> org.apache.olingo.client.core.http.DefaultHttpClientFactory which is -
> not surprisingly - the default
>
> client.getConfiguration().setHttpClientFactory(yourOwnFactory);
>
>
> There are some client factories provided for common usages - basic
> authentication, NTLM authentication, OAuth 2.0, proxy - in [1] and
> more samples of how to customize the HttpClient instances under [2].
>
> HTH
> Regards.
>
> [1] https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;
> a=tree;f=lib/client-core/src/main/java/org/apache/olingo/client/core/http
> [2] https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;
> a=tree;f=samples/client/src/main/java/org/apache/olingo/
> samples/client/core/http
>
> --
> Francesco Chicchiriccò
>
> Tirasa - Open Source Excellence
> http://www.tirasa.net/
>
> Involved at The Apache Software Foundation:
> member, Syncope PMC chair, Cocoon PMC, Olingo PMC
> http://people.apache.org/~ilgrosso/
>
>
>


-- 


Vincenzo Turco

Re: passing arbitrary org.apache.http.client.HttpClient instance to Olingo Client

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 25/09/2014 19:06, Vincenzo Turco wrote:
> Hi all,
> I'd like to use Olingo as client to my OData services.
> My current application server runtime can provide an HttpClient instance.
> I'd like to pass this object to Olingo API so that connection to the OData
> endpoint could take place through it.
> This would be important because the HttpClient instance already has lots of
> authentication properties configured by the application server runtime.
> Could anyone please direct me to relevant docs?

Hi Vincenzo,
if you want to provide your own HttpClient instance, you'll need to

1. create your own org.apache.olingo.client.api.http.HttpClientFactory 
implementation (or just extend 
org.apache.olingo.client.core.http.AbstractHttpClientFactory)

2. set your client instance to use your own HttpClientFactory and not 
org.apache.olingo.client.core.http.DefaultHttpClientFactory which is - 
not surprisingly - the default

client.getConfiguration().setHttpClientFactory(yourOwnFactory);


There are some client factories provided for common usages - basic 
authentication, NTLM authentication, OAuth 2.0, proxy - in [1] and
more samples of how to customize the HttpClient instances under [2].

HTH
Regards.

[1] 
https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=tree;f=lib/client-core/src/main/java/org/apache/olingo/client/core/http
[2] 
https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=tree;f=samples/client/src/main/java/org/apache/olingo/samples/client/core/http

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/