Friday, September 3, 2010

Follow HTTP redirects -OSB HTTP Transport Level setting


I started on the journey with Oracle service bus very recently even though I have been trying to catch this bus for a long time, but was never quite successful. It was quite different approach as considered to the more commonly used BPEL and ESB approach. Getting used to the Eclipse IDE, then exploring different options takes bit of your  time to get familiarized. But as always new journeys give us more opportunities to learn.
One of the first hurdles that came up was with testing the business service. The scenario goes like this. There is a web service exposed in one of our target systems which we tried to consume as a Business service from OSB. Developing the Business service is very straight forward, but testing it and making it work looked cumbersome. As part of testing we were encountering ‘Bad Request’ Error even though the payload was thoroughly tested using SOAP UI. The response code returns response code as 400 which meant that the request was not even reaching the web service.
What OSB gives us to debug the issue?
OSB Console test window will give you Response Document and Response Metadata using which you need to figure out the error.
Response Document returns
The invocation resulted in an error: Bad Request.
Response Metadata returns
<con:metadata xmlns:con="http://www.bea.com/wli/sb/test/config">
            <tran:headers             xsi:type="http:HttpResponseHeaders" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:tran="http://www.bea.com/wli/sb/transports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <http:Connection>close</http:Connection>
            <http:Content-Type>text/html; charset=iso-8859-1</http:Content-Type>
            <http:Date>Fri, 03 Sep 2010 05:11:17 GMT</http:Date>
            <http:Transfer-Encoding>chunked</http:Transfer-Encoding>
            </tran:headers>
            <tran:response-code   xmlns:tran="http://www.bea.com/wli/sb/transports">1</tran:response-code>
            <tran:response-message         xmlns:tran="http://www.bea.com/wli/sb/transports">Bad Request</tran:response-message>
            <tran:encoding           xmlns:tran="http://www.bea.com/wli/sb/transports">iso-8859-1</tran:encoding>
            <http:http-response-code         xmlns:http="http://www.bea.com/wli/sb/transports/http">400</http:http-response-code>
            </con:metadata>

So after a bit analysis and help from the Mohan the issue was found that the request was not getting forwarded to the external system and to ensure that the request gets forwarded to the end system  we need to enable  Follow HTTP redirects  setting . By default HTTP redirect will be disabled.
How to enable the HTTP redirect setting?
Go to HTTP Transport tab in the business service.biz file. Go to Advanced settings -> Enable Follow HTTP redirects

What Follow HTTP redirects setting does?
               A re-direct occurs when you send an outbound request to the URL of a business service, and that service returns a response code (for example, 302) that says the URL is no longer valid and this request needs to be sent to another URL. If the Follow HTTP Redirects check box is selected, Oracle Service Bus automatically re-sends the request to the new URL without any action on your part.
Note:
Another point to note is that 'chunked streaming mode' and 'follow HTTP redirects' setting cannot be enabled together. By default 'chunked streaming mode' will be enabled and HTTP redirects will be disabled. If you try to enable both settings of a business service, it will throw a compile time error mentioning
HTTP business service cannot have both 'chunked streaming mode' and 'follow HTTP redirects' options enabled.       
That’s it to start off with, m back to work J

7 comments:

Anonymous said...

Good stuff

Anonymous said...

Thanks. This helped me to solve my problem

Anonymous said...

good one..

Nauman AHmed said...

God Bless!!! I spent lot of time breaking my head to figure this out....

Anonymous said...

This typically does not work for me on a 302 request inspite of configuring follow redirects on the business service.

ACTIVE] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <004pIS3DH22FW71LRup2id0001^x000PY1> <1360263441158> <
[OSB Tracing] Outbound request was sent.

Service Ref = calculator/business/calculatorlb
URI = http://test.ws.osb.com/calculator/proxy/calculator
Request metadata =


text/xml; charset=utf-8
""

utf-8

Payload =



3
3

>
#### <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1360263441163> <
[OSB Tracing] Outbound response was received.

Service Ref = calculator/business/calculatorlb
URI = http://test.ws.osb.com/calculator/proxy/calculator
Error code = BEA-380000
Error Message = Moved Temporarily
Message ID = 6779523171584152305-1815c7fe.13cb50c66a6.-6970
Response metadata =


<cookie-values xmlns="http://www.bea.com/wli/sb/transports/http">
<value>NSC_uftu.xt.ptc.ijehmpcbm.dpn=ffffffff09c95f7345525d5f4f58455e445a4a42297b;expires=Fri, 08-Feb-2013 18:57:21 GMT;path=/</value>
</cookie-values>

1
Moved Temporarily
iso-8859-1
-1

Payload =

>
#### <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1360263441163> <
[OSB Tracing] Outbound response was received.

Service Ref = calculator/business/calculatorlb
URI = http://test.ws.osb.com/calculator/proxy/calculator
Error code = BEA-380000
Error Message = Moved Temporarily
Message ID = 6779523171584152305-1815c7fe.13cb50c66a6.-6970
Response metadata =


<cookie-values xmlns="http://www.bea.com/wli/sb/transports/http">
<value>NSC_uftu.xt.ptc.ijehmpcbm.dpn=ffffffff09c95f7345525d5f4f58455e445a4a42297b;expires=Fri, 08-Feb-2013 18:57:21 GMT;path=/</value>
</cookie-values>

1
Moved Temporarily
iso-8859-1
-1

Payload =

>

Any idea why??

Anonymous said...

Hi,

This 302 - Temporary move http status does not work for me . It is typically supposed to redirect with this flag but does not apparently work here.

ACTIVE] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <004pIS3DH22FW71LRup2id0001^x000PY1> <1360263441158> <
[OSB Tracing] Outbound request was sent.

Service Ref = calculator/business/calculatorlb
URI = http://test.ws.osb.com/calculator/proxy/calculator
Request metadata =


text/xml; charset=utf-8
""

utf-8

Payload =



3
3

>
#### <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1360263441163> <
[OSB Tracing] Outbound response was received.

Service Ref = calculator/business/calculatorlb
URI = http://test.ws.osb.com/calculator/proxy/calculator
Error code = BEA-380000
Error Message = Moved Temporarily
Message ID = 6779523171584152305-1815c7fe.13cb50c66a6.-6970
Response metadata =


<cookie-values xmlns="http://www.bea.com/wli/sb/transports/http">
<value>NSC_uftu.xt.ptc.ijehmpcbm.dpn=ffffffff09c95f7345525d5f4f58455e445a4a42297b;expires=Fri, 08-Feb-2013 18:57:21 GMT;path=/</value>
</cookie-values>

1
Moved Temporarily
iso-8859-1
-1

Payload =

>
#### <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1360263441163> <
[OSB Tracing] Outbound response was received.

Service Ref = calculator/business/calculatorlb
URI = http://test.ws.osb.com/calculator/proxy/calculator
Error code = BEA-380000
Error Message = Moved Temporarily
Message ID = 6779523171584152305-1815c7fe.13cb50c66a6.-6970
Response metadata =


<cookie-values xmlns="http://www.bea.com/wli/sb/transports/http">
<value>NSC_uftu.xt.ptc.ijehmpcbm.dpn=ffffffff09c95f7345525d5f4f58455e445a4a42297b;expires=Fri, 08-Feb-2013 18:57:21 GMT;path=/</value>
</cookie-values>

1
Moved Temporarily
iso-8859-1
-1

Payload =

>

Any ideas??

Cheers,
Mitz

Anonymous said...

This setting helps while invoking Siebel EAI service when you are getting "Supplied input is not well formed or does not contain the expected data.(SBL-EAI-00137)" error.