You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by emilSverige <es...@gmail.com> on 2008/12/18 09:59:39 UTC

Client doesn't follow redirect

Hi,
I have a load balanced SAP web service residing. 
I have generated CXF java client code to connect to this service. It works
fine if I connect directly to the service, but fails if I try to connect via
the load balancer. I believe the server is responding with status 301, but I
haven't been able to confirm that.
I have set autoredirect=true, but nothing changes.

How can I confirm that a response 301 is sent from the server? I see nothing
about it in the logs. It looks like a 301 in the logs, but I would say it
looks like it returns some HTML code instead. I tried debugging, but don't
know where to look.

This is the logs:

2008-dec-18 09:49:33 org.apache.cxf.transport.http.HTTPConduit prepare
INFO: AutoRedirect is turned on.
2008-dec-18 09:49:33
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
Encoding: UTF-8
Headers: {Authorization=[Basic UElBUFBMVVNFUjpzYXA0Y29sbA==],
SOAPAction=[""], Accept=[*]}
Messages: 
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:ZSteriaId
xmlns:ns2="urn:sap-com:document:sap:soap:functions:mc-style"><IvId>165566361159K97732</IvId></ns2:ZSteriaId></soap:Body></soap:Envelope>
--------------------------------------
2008-dec-18 09:49:33 org.apache.cxf.interceptor.LoggingInInterceptor logging
INFO: Inbound Message
----------------------------
Encoding: UTF-8
Headers: {content-type=[text/html; charset=utf-8], connection=[close],
host=[sapcr:8160],
location=[http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_steria_id_retur/z_steria_id_retur],
Content-Length=[325], server=[SAP Message Server, release 700 (PCR)],
date=[Thu, 18 Dec 2008 08:49:33 GMT]}
Messages: 
Message:

Payload: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 MOVED PERMANENTLY</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved 
http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_steria_id_retur/z_steria_id_retur 
here 
</BODY></HTML>

--------------------------------------
2008-dec-18 09:49:33 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Response was of unexpected text/html
ContentType.  Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 MOVED PERMANENTLY</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved 
http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_steria_id_retur/z_steria_id_retur 
here 
</BODY></HTML>

	at
org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:73)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
	at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:633)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2064)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1942)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1867)
	at
org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)
	at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:170)
	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:595)
	at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:466)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251)
	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
	at $Proxy41.zSteriaId(Unknown Source)
	at se.collectum.pki.utils.SteriaId2CrmId.convert(SteriaId2CrmId.java:53)
-- 
View this message in context: http://www.nabble.com/Client-doesn%27t-follow-redirect-tp21069032p21069032.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Client doesn't follow redirect

Posted by Glen Mazza <gl...@gmail.com>.
I would look at Wireshark (google), it will give you the HTTP status response
codes.

Glen


emilSverige wrote:
> 
> How can I confirm that a response 301 is sent from the server? I see
> nothing about it in the logs. It looks like a 301 in the logs, but I would
> say it looks like it returns some HTML code instead. I tried debugging,
> but don't know where to look.
> 

-- 
View this message in context: http://www.nabble.com/Client-doesn%27t-follow-redirect-tp21069032p21072103.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Client doesn't follow redirect

Posted by emilSverige <es...@gmail.com>.
I noted that it had already been fixed in the main branch. I downloaded the
source code for 2.13, applied the fix and built a new jar file. i don't want
to deploy any unstable versions to our production environment.

I have tested the fix and it solves my problem. Thank you so much for your
help!

/Emil
-- 
View this message in context: http://www.nabble.com/Client-doesn%27t-follow-redirect-tp21069032p21297120.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Client doesn't follow redirect

Posted by Daniel Kulp <dk...@apache.org>.
On Monday 29 December 2008 10:59:52 am emilSverige wrote:
> Hi again
> What can I do to fix this? Should I edit the source code and package my own
> cxf jar file? Or should I wait for a new release where this is fixed and
> work around it in the meantime?
> What would you suggest?

If possible, I would suggest using the latest 2.1.4-SNAPSHOT:
http://people.apache.org/repo/m2-snapshot-repository/org/apache/cxf/apache-cxf/2.1.4-SNAPSHOT/

I'll try and get new snapshot builds up later today or tomorrow that should 
contain even more fixes.


-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: Client doesn't follow redirect

Posted by emilSverige <es...@gmail.com>.
Hi again
What can I do to fix this? Should I edit the source code and package my own
cxf jar file? Or should I wait for a new release where this is fixed and
work around it in the meantime? 
What would you suggest?

Kind regards
Emil
-- 
View this message in context: http://www.nabble.com/Client-doesn%27t-follow-redirect-tp21069032p21205052.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Client doesn't follow redirect

Posted by emilSverige <es...@gmail.com>.
Hi, thank you all for your help. The case sensitivity seems likely to be
problem. I will look into it when I'm back from the holiday.

Regards
Emil
-- 
View this message in context: http://www.nabble.com/Client-doesn%27t-follow-redirect-tp21069032p21107982.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Client doesn't follow redirect

Posted by Glen Mazza <gl...@gmail.com>.
Yes, according to Section 4.2 of the HTTP spec
(http://tools.ietf.org/html/rfc2616#section-4.2) header field names are
case-insensitive.

Glen


dkulp wrote:
> 
> I think I see the problem....
> 
> Your headers that are returning have:
> location=[http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_steria_id_retur/z_steria_id_retur]
> 
> However, we are calling:
>  List<String> locs = headers.get("Location");
> (notice the capital L)   Thus, I'm pretty sure its not finding the new 
> location to redirect to.  Relatively simple fix...  We can loop through
> the 
> keyset doing an equalsIgnoreCase.
> 
> Dan 
> 

-- 
View this message in context: http://www.nabble.com/Client-doesn%27t-follow-redirect-tp21069032p21081263.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Client doesn't follow redirect

Posted by Daniel Kulp <dk...@apache.org>.
I think I see the problem....

Your headers that are returning have:
location=[http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_steria_id_retur/z_steria_id_retur]

However, we are calling:
 List<String> locs = headers.get("Location");
(notice the capital L)   Thus, I'm pretty sure its not finding the new 
location to redirect to.  Relatively simple fix...  We can loop through the 
keyset doing an equalsIgnoreCase.

Dan 


On Thursday 18 December 2008 3:59:39 am emilSverige wrote:
> Hi,
> I have a load balanced SAP web service residing.
> I have generated CXF java client code to connect to this service. It works
> fine if I connect directly to the service, but fails if I try to connect
> via the load balancer. I believe the server is responding with status 301,
> but I haven't been able to confirm that.
> I have set autoredirect=true, but nothing changes.
>
> How can I confirm that a response 301 is sent from the server? I see
> nothing about it in the logs. It looks like a 301 in the logs, but I would
> say it looks like it returns some HTML code instead. I tried debugging, but
> don't know where to look.
>
> This is the logs:
>
> 2008-dec-18 09:49:33 org.apache.cxf.transport.http.HTTPConduit prepare
> INFO: AutoRedirect is turned on.
> 2008-dec-18 09:49:33
> org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
> INFO: Outbound Message
> ---------------------------
> Encoding: UTF-8
> Headers: {Authorization=[Basic UElBUFBMVVNFUjpzYXA0Y29sbA==],
> SOAPAction=[""], Accept=[*]}
> Messages:
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:ZSte
>riaId
> xmlns:ns2="urn:sap-com:document:sap:soap:functions:mc-style"><IvId>16556636
>1159K97732</IvId></ns2:ZSteriaId></soap:Body></soap:Envelope>
> --------------------------------------
> 2008-dec-18 09:49:33 org.apache.cxf.interceptor.LoggingInInterceptor
> logging INFO: Inbound Message
> ----------------------------
> Encoding: UTF-8
> Headers: {content-type=[text/html; charset=utf-8], connection=[close],
> host=[sapcr:8160],
> location=[http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_s
>teria_id_retur/z_steria_id_retur], Content-Length=[325], server=[SAP Message
> Server, release 700 (PCR)], date=[Thu, 18 Dec 2008 08:49:33 GMT]}
> Messages:
> Message:
>
> Payload: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD>
> <TITLE>301 MOVED PERMANENTLY</TITLE>
> </HEAD><BODY>
> <H1>Moved Permanently</H1>
> The document has moved
> http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_steria_id_r
>etur/z_steria_id_retur here
> </BODY></HTML>
>
> --------------------------------------
> 2008-dec-18 09:49:33 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Response was of unexpected text/html
> ContentType.  Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC
> "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD>
> <TITLE>301 MOVED PERMANENTLY</TITLE>
> </HEAD><BODY>
> <H1>Moved Permanently</H1>
> The document has moved
> http://sapprd02:8060/sap/bc/srt/rfc/sap/z_steria_id_retur/100/z_steria_id_r
>etur/z_steria_id_retur here
> </BODY></HTML>
>
> 	at
> org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInIntercepto
>r.java:73) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:220) at
> org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:633) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
>eInternal(HTTPConduit.java:2064) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
>e(HTTPConduit.java:1942) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
>duit.java:1867) at
> org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputSt
>ream.java:47) at
> org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:170) at
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) at
> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:595) at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte
>rceptor.handleMessage(MessageSenderInterceptor.java:62) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:220) at
> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:466) at
> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299) at
> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251) at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) at
> $Proxy41.zSteriaId(Unknown Source)
> 	at se.collectum.pki.utils.SteriaId2CrmId.convert(SteriaId2CrmId.java:53)



-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog