You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Marco Mans <ma...@telemans.de> on 2013/09/26 16:01:26 UTC

Relative Redirect

Hi Folks!

I have some problems with a webservice that uses a relative redirect.
This is what is happening:
1. I send a request to http://mydomain.com/webservice.asmx
2. The webservice answers with a HTTP 302 and sets the location to
/(12323123312)/webservice.asmx
3. CXF autmatically redirects and send a second request to
http://mydomain.com/webservice.asmx/(12323123312)/webservice.asmx

Instead of replacing the root of my path it simply adds the relative
redirection at the end of the original request.

This code I use to enable autoredirection:
<snippet>
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(MyWebServiceSoap.class);
factory.setAddress("http://mydomain.com/webservice.asmx");
service = (GensysWebServiceSoap) factory.create();

Client client = ClientProxy.getClient(service);
((HTTPConduit) (client.getConduit())).getClient().setAutoRedirect(true);
client.getBus().getProperties().put("http.redirect.relative.uri", true);
</snippet>

Does anyone knows how to fix this?

Thanks in advance!!!

Greetz,
Marco Mans

Re: Relative Redirect

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Marco
On 30/09/13 16:04, Marco Mans wrote:
> Hi Sergey,
>
> That sounds good. What would you recommend in teh meantime? Could I use
> interceptors that check if the location is changed?
>
I think that realistically it has to be done manually for now - catch a 
redirect exception and create a new client with a new Location.
I'm not exactly sure though how to handle a redirect exception and 
specifically, get a Location value, in JAX-WS, may be with the custom
in fault interceptor ?



Cheers, Sergey

> Marco
>
>
> 2013/9/30 Sergey Beryozkin <sb...@gmail.com>
>
>> Hi Marco
>>
>> On 30/09/13 13:31, Marco Mans wrote:
>>
>>> Hi Sergey!
>>>
>>> Thanks for the quick response! I just tried with the 2.7.8-SNAPSHOT
>>> version.
>>> Relative redirection is working now!
>>>
>>>   Thanks for confirming it
>>
>>   I noticed that a second call, with the same client is done to the 'old'
>>> location.
>>> The redirection adds a session-id to the url. So it is important to keep
>>> this id in the URL.
>>> Is there a setting that enables this?
>>>
>>>   I think it is a general issue with auto-redirects is that a new Location
>> is not set as the current client's request URI/endpoint address.
>> As far as I recall, a load balancing feature has the same draw-back, as
>> opposed to a fail-over feature.
>>
>> I'm thinking of introducing an interface, say, TransportCallback. The
>> frontend clients will set it internally and HttpConduit or other code which
>> auto-updates the request address will call back on TransportCallback if it
>> is available - this will let the clients update the current request URI as
>> needed per the rules of a given frontend.
>> Introducing events may be another option but I wonder if it can have some
>> thread-safety issues...
>>
>> Something like that
>>
>> Sergey
>>
>>
>>   Greetz,
>>> Marco
>>>
>>>
>>>
>>> 2013/9/26 Sergey Beryozkin <sb...@gmail.com>
>>>
>>>   I replaced the manual resolution code I added originally with URI resolve
>>>> call - that should fix the issue; also add a new
>>>> "max.http.redirect.count"
>>>> property - can be used to prevent the client from spinning...
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>> On 26/09/13 15:38, Sergey Beryozkin wrote:
>>>>
>>>>   Hi
>>>>>
>>>>> Yes, I can see it does not resolve it correctly, I have a test but a bit
>>>>> more work is needed. I'll update you when I'm done
>>>>>
>>>>> Sergey
>>>>>
>>>>> On 26/09/13 15:01, Marco Mans wrote:
>>>>>
>>>>>   Hi Folks!
>>>>>>
>>>>>> I have some problems with a webservice that uses a relative redirect.
>>>>>> This is what is happening:
>>>>>> 1. I send a request to http://mydomain.com/****webservice.asmx<http://mydomain.com/**webservice.asmx>
>>>>>> <http://**mydomain.com/webservice.asmx<http://mydomain.com/webservice.asmx>
>>>>>>>
>>>>>>
>>>>>> 2. The webservice answers with a HTTP 302 and sets the location to
>>>>>> /(12323123312)/webservice.asmx
>>>>>> 3. CXF autmatically redirects and send a second request to
>>>>>> http://mydomain.com/****webservice.asmx/(12323123312)/**
>>>>>> **webservice.asmx<http://mydomain.com/**webservice.asmx/(12323123312)/**webservice.asmx>
>>>>>> <http://**mydomain.com/webservice.asmx/(**12323123312)/webservice.asmx<http://mydomain.com/webservice.asmx/(12323123312)/webservice.asmx>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> Instead of replacing the root of my path it simply adds the relative
>>>>>> redirection at the end of the original request.
>>>>>>
>>>>>> This code I use to enable autoredirection:
>>>>>> <snippet>
>>>>>> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>>>>>> factory.setServiceClass(****MyWebServiceSoap.class);
>>>>>> factory.setAddress("http://**m**ydomain.com/webservice.asmx<http://mydomain.com/webservice.asmx>
>>>>>> <ht**tp://mydomain.com/webservice.**asmx<http://mydomain.com/webservice.asmx>
>>>>>>>
>>>>>> ")**;
>>>>>> service = (GensysWebServiceSoap) factory.create();
>>>>>>
>>>>>> Client client = ClientProxy.getClient(service)****;
>>>>>> ((HTTPConduit) (client.getConduit())).****
>>>>>> getClient().setAutoRedirect(**
>>>>>> true);
>>>>>> client.getBus().getProperties(****).put("http.redirect.**
>>>>>> relative.**uri",
>>>>>>
>>>>>> true);
>>>>>> </snippet>
>>>>>>
>>>>>> Does anyone knows how to fix this?
>>>>>>
>>>>>> Thanks in advance!!!
>>>>>>
>>>>>> Greetz,
>>>>>> Marco Mans
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>>>
>>>>
>>>
>>
>


Re: Relative Redirect

Posted by Marco Mans <ma...@telemans.de>.
Hi Sergey,

That sounds good. What would you recommend in teh meantime? Could I use
interceptors that check if the location is changed?

Marco


2013/9/30 Sergey Beryozkin <sb...@gmail.com>

> Hi Marco
>
> On 30/09/13 13:31, Marco Mans wrote:
>
>> Hi Sergey!
>>
>> Thanks for the quick response! I just tried with the 2.7.8-SNAPSHOT
>> version.
>> Relative redirection is working now!
>>
>>  Thanks for confirming it
>
>  I noticed that a second call, with the same client is done to the 'old'
>> location.
>> The redirection adds a session-id to the url. So it is important to keep
>> this id in the URL.
>> Is there a setting that enables this?
>>
>>  I think it is a general issue with auto-redirects is that a new Location
> is not set as the current client's request URI/endpoint address.
> As far as I recall, a load balancing feature has the same draw-back, as
> opposed to a fail-over feature.
>
> I'm thinking of introducing an interface, say, TransportCallback. The
> frontend clients will set it internally and HttpConduit or other code which
> auto-updates the request address will call back on TransportCallback if it
> is available - this will let the clients update the current request URI as
> needed per the rules of a given frontend.
> Introducing events may be another option but I wonder if it can have some
> thread-safety issues...
>
> Something like that
>
> Sergey
>
>
>  Greetz,
>> Marco
>>
>>
>>
>> 2013/9/26 Sergey Beryozkin <sb...@gmail.com>
>>
>>  I replaced the manual resolution code I added originally with URI resolve
>>> call - that should fix the issue; also add a new
>>> "max.http.redirect.count"
>>> property - can be used to prevent the client from spinning...
>>>
>>> Cheers, Sergey
>>>
>>>
>>> On 26/09/13 15:38, Sergey Beryozkin wrote:
>>>
>>>  Hi
>>>>
>>>> Yes, I can see it does not resolve it correctly, I have a test but a bit
>>>> more work is needed. I'll update you when I'm done
>>>>
>>>> Sergey
>>>>
>>>> On 26/09/13 15:01, Marco Mans wrote:
>>>>
>>>>  Hi Folks!
>>>>>
>>>>> I have some problems with a webservice that uses a relative redirect.
>>>>> This is what is happening:
>>>>> 1. I send a request to http://mydomain.com/****webservice.asmx<http://mydomain.com/**webservice.asmx>
>>>>> <http://**mydomain.com/webservice.asmx<http://mydomain.com/webservice.asmx>
>>>>> >
>>>>>
>>>>> 2. The webservice answers with a HTTP 302 and sets the location to
>>>>> /(12323123312)/webservice.asmx
>>>>> 3. CXF autmatically redirects and send a second request to
>>>>> http://mydomain.com/****webservice.asmx/(12323123312)/**
>>>>> **webservice.asmx<http://mydomain.com/**webservice.asmx/(12323123312)/**webservice.asmx>
>>>>> <http://**mydomain.com/webservice.asmx/(**12323123312)/webservice.asmx<http://mydomain.com/webservice.asmx/(12323123312)/webservice.asmx>
>>>>> >
>>>>>
>>>>>
>>>>> Instead of replacing the root of my path it simply adds the relative
>>>>> redirection at the end of the original request.
>>>>>
>>>>> This code I use to enable autoredirection:
>>>>> <snippet>
>>>>> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>>>>> factory.setServiceClass(****MyWebServiceSoap.class);
>>>>> factory.setAddress("http://**m**ydomain.com/webservice.asmx<http://mydomain.com/webservice.asmx>
>>>>> <ht**tp://mydomain.com/webservice.**asmx<http://mydomain.com/webservice.asmx>
>>>>> >
>>>>> ")**;
>>>>> service = (GensysWebServiceSoap) factory.create();
>>>>>
>>>>> Client client = ClientProxy.getClient(service)****;
>>>>> ((HTTPConduit) (client.getConduit())).****
>>>>> getClient().setAutoRedirect(**
>>>>> true);
>>>>> client.getBus().getProperties(****).put("http.redirect.**
>>>>> relative.**uri",
>>>>>
>>>>> true);
>>>>> </snippet>
>>>>>
>>>>> Does anyone knows how to fix this?
>>>>>
>>>>> Thanks in advance!!!
>>>>>
>>>>> Greetz,
>>>>> Marco Mans
>>>>>
>>>>>
>>>>>
>>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>>
>>
>

Re: Relative Redirect

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Marco
On 30/09/13 13:31, Marco Mans wrote:
> Hi Sergey!
>
> Thanks for the quick response! I just tried with the 2.7.8-SNAPSHOT version.
> Relative redirection is working now!
>
Thanks for confirming it
> I noticed that a second call, with the same client is done to the 'old'
> location.
> The redirection adds a session-id to the url. So it is important to keep
> this id in the URL.
> Is there a setting that enables this?
>
I think it is a general issue with auto-redirects is that a new Location 
is not set as the current client's request URI/endpoint address.
As far as I recall, a load balancing feature has the same draw-back, as 
opposed to a fail-over feature.

I'm thinking of introducing an interface, say, TransportCallback. The 
frontend clients will set it internally and HttpConduit or other code 
which auto-updates the request address will call back on 
TransportCallback if it is available - this will let the clients update 
the current request URI as needed per the rules of a given frontend.
Introducing events may be another option but I wonder if it can have 
some thread-safety issues...

Something like that

Sergey


> Greetz,
> Marco
>
>
>
> 2013/9/26 Sergey Beryozkin <sb...@gmail.com>
>
>> I replaced the manual resolution code I added originally with URI resolve
>> call - that should fix the issue; also add a new "max.http.redirect.count"
>> property - can be used to prevent the client from spinning...
>>
>> Cheers, Sergey
>>
>>
>> On 26/09/13 15:38, Sergey Beryozkin wrote:
>>
>>> Hi
>>>
>>> Yes, I can see it does not resolve it correctly, I have a test but a bit
>>> more work is needed. I'll update you when I'm done
>>>
>>> Sergey
>>>
>>> On 26/09/13 15:01, Marco Mans wrote:
>>>
>>>> Hi Folks!
>>>>
>>>> I have some problems with a webservice that uses a relative redirect.
>>>> This is what is happening:
>>>> 1. I send a request to http://mydomain.com/**webservice.asmx<http://mydomain.com/webservice.asmx>
>>>> 2. The webservice answers with a HTTP 302 and sets the location to
>>>> /(12323123312)/webservice.asmx
>>>> 3. CXF autmatically redirects and send a second request to
>>>> http://mydomain.com/**webservice.asmx/(12323123312)/**webservice.asmx<http://mydomain.com/webservice.asmx/(12323123312)/webservice.asmx>
>>>>
>>>> Instead of replacing the root of my path it simply adds the relative
>>>> redirection at the end of the original request.
>>>>
>>>> This code I use to enable autoredirection:
>>>> <snippet>
>>>> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>>>> factory.setServiceClass(**MyWebServiceSoap.class);
>>>> factory.setAddress("http://**mydomain.com/webservice.asmx<http://mydomain.com/webservice.asmx>
>>>> ")**;
>>>> service = (GensysWebServiceSoap) factory.create();
>>>>
>>>> Client client = ClientProxy.getClient(service)**;
>>>> ((HTTPConduit) (client.getConduit())).**getClient().setAutoRedirect(**
>>>> true);
>>>> client.getBus().getProperties(**).put("http.redirect.relative.**uri",
>>>> true);
>>>> </snippet>
>>>>
>>>> Does anyone knows how to fix this?
>>>>
>>>> Thanks in advance!!!
>>>>
>>>> Greetz,
>>>> Marco Mans
>>>>
>>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>


Re: Relative Redirect

Posted by Marco Mans <ma...@telemans.de>.
Hi Sergey!

Thanks for the quick response! I just tried with the 2.7.8-SNAPSHOT version.
Relative redirection is working now!

I noticed that a second call, with the same client is done to the 'old'
location.
The redirection adds a session-id to the url. So it is important to keep
this id in the URL.
Is there a setting that enables this?

Greetz,
Marco



2013/9/26 Sergey Beryozkin <sb...@gmail.com>

> I replaced the manual resolution code I added originally with URI resolve
> call - that should fix the issue; also add a new "max.http.redirect.count"
> property - can be used to prevent the client from spinning...
>
> Cheers, Sergey
>
>
> On 26/09/13 15:38, Sergey Beryozkin wrote:
>
>> Hi
>>
>> Yes, I can see it does not resolve it correctly, I have a test but a bit
>> more work is needed. I'll update you when I'm done
>>
>> Sergey
>>
>> On 26/09/13 15:01, Marco Mans wrote:
>>
>>> Hi Folks!
>>>
>>> I have some problems with a webservice that uses a relative redirect.
>>> This is what is happening:
>>> 1. I send a request to http://mydomain.com/**webservice.asmx<http://mydomain.com/webservice.asmx>
>>> 2. The webservice answers with a HTTP 302 and sets the location to
>>> /(12323123312)/webservice.asmx
>>> 3. CXF autmatically redirects and send a second request to
>>> http://mydomain.com/**webservice.asmx/(12323123312)/**webservice.asmx<http://mydomain.com/webservice.asmx/(12323123312)/webservice.asmx>
>>>
>>> Instead of replacing the root of my path it simply adds the relative
>>> redirection at the end of the original request.
>>>
>>> This code I use to enable autoredirection:
>>> <snippet>
>>> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>>> factory.setServiceClass(**MyWebServiceSoap.class);
>>> factory.setAddress("http://**mydomain.com/webservice.asmx<http://mydomain.com/webservice.asmx>
>>> ")**;
>>> service = (GensysWebServiceSoap) factory.create();
>>>
>>> Client client = ClientProxy.getClient(service)**;
>>> ((HTTPConduit) (client.getConduit())).**getClient().setAutoRedirect(**
>>> true);
>>> client.getBus().getProperties(**).put("http.redirect.relative.**uri",
>>> true);
>>> </snippet>
>>>
>>> Does anyone knows how to fix this?
>>>
>>> Thanks in advance!!!
>>>
>>> Greetz,
>>> Marco Mans
>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>

Re: Relative Redirect

Posted by Sergey Beryozkin <sb...@gmail.com>.
I replaced the manual resolution code I added originally with URI 
resolve call - that should fix the issue; also add a new 
"max.http.redirect.count" property - can be used to prevent the client 
from spinning...

Cheers, Sergey

On 26/09/13 15:38, Sergey Beryozkin wrote:
> Hi
>
> Yes, I can see it does not resolve it correctly, I have a test but a bit
> more work is needed. I'll update you when I'm done
>
> Sergey
>
> On 26/09/13 15:01, Marco Mans wrote:
>> Hi Folks!
>>
>> I have some problems with a webservice that uses a relative redirect.
>> This is what is happening:
>> 1. I send a request to http://mydomain.com/webservice.asmx
>> 2. The webservice answers with a HTTP 302 and sets the location to
>> /(12323123312)/webservice.asmx
>> 3. CXF autmatically redirects and send a second request to
>> http://mydomain.com/webservice.asmx/(12323123312)/webservice.asmx
>>
>> Instead of replacing the root of my path it simply adds the relative
>> redirection at the end of the original request.
>>
>> This code I use to enable autoredirection:
>> <snippet>
>> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>> factory.setServiceClass(MyWebServiceSoap.class);
>> factory.setAddress("http://mydomain.com/webservice.asmx");
>> service = (GensysWebServiceSoap) factory.create();
>>
>> Client client = ClientProxy.getClient(service);
>> ((HTTPConduit) (client.getConduit())).getClient().setAutoRedirect(true);
>> client.getBus().getProperties().put("http.redirect.relative.uri", true);
>> </snippet>
>>
>> Does anyone knows how to fix this?
>>
>> Thanks in advance!!!
>>
>> Greetz,
>> Marco Mans
>>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Relative Redirect

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Yes, I can see it does not resolve it correctly, I have a test but a bit 
more work is needed. I'll update you when I'm done

Sergey

On 26/09/13 15:01, Marco Mans wrote:
> Hi Folks!
>
> I have some problems with a webservice that uses a relative redirect.
> This is what is happening:
> 1. I send a request to http://mydomain.com/webservice.asmx
> 2. The webservice answers with a HTTP 302 and sets the location to
> /(12323123312)/webservice.asmx
> 3. CXF autmatically redirects and send a second request to
> http://mydomain.com/webservice.asmx/(12323123312)/webservice.asmx
>
> Instead of replacing the root of my path it simply adds the relative
> redirection at the end of the original request.
>
> This code I use to enable autoredirection:
> <snippet>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.setServiceClass(MyWebServiceSoap.class);
> factory.setAddress("http://mydomain.com/webservice.asmx");
> service = (GensysWebServiceSoap) factory.create();
>
> Client client = ClientProxy.getClient(service);
> ((HTTPConduit) (client.getConduit())).getClient().setAutoRedirect(true);
> client.getBus().getProperties().put("http.redirect.relative.uri", true);
> </snippet>
>
> Does anyone knows how to fix this?
>
> Thanks in advance!!!
>
> Greetz,
> Marco Mans
>