473,409 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Redirect results in lost soap envelope. Changes method from POST to GET

Hello,

I created a web site, site A, that redirects to another web site, site
B, where a simple web service is hosted. The code to call the web
service is simple.

oWS.AllowAutoRedirect = True
oWS.Credentials = New
System.Net.NetworkCredential("user","pass")
str = oWS.HelloWorld("World")

When I set the URI of the webservice to site B an http trace shows the
following.
POST 401 text/html http://siteB/redirect_test/service.asmx
POST 401 text/html http://siteB/redirect_test/service.asmx
POST 200 text/xml http://siteB/redirect_test/service.asmx

The result of the call
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"
xmlns:xsd="http://www.w3.org/2001/
XMLSchema">
<soap:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>Hello World</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>

When I try to test the redirect from site A to site B, I get the
following trace.
POST 301 text/html http://siteA/redirect_test/service.asmx
http://siteB/redirect_test/service.asmx
GET 401 text/html http://siteB/redirect_test/service.asmx
GET 401 text/html http://siteB/redirect_test/service.asmx
GET 200 text/html http://siteB/redirect_test/service.asmx

The result of this call is too long to post and be meaning full, but
the content is the list of methods for the web service. I am sure
most of you are familiar with the html rendering of the .asmx page
that lists the methods.

In both traces you will see 2 lines containing a 401. You can be
assured that security is not an issue. The 401's are a result of the
handshake that takes place to ensure that the user is valid.

The issue appears to be that the initial POST is getting changed to a
GET during the redirect. Thus the post stream that contains my SOAP
envelope is stripped and not sent to the web service at the new site.

If anyone has any ideas on why this may be happening and the best
method for resolving this issue I would greatly appreciate it.

This has been tested using web services hosted on IIS 6.0 and SAP
Netweaver 2004 & SAP ECC 5.0. The calling application was written
using VB.net in Visual Studio 2005. The .net framework version is 2.0
and the useragent string for the calling application is Mozilla/4.0
(compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.42).

If you need any more information about the environment or the calls
being made. Do not hesitate to post them and I will answer them to
the best of my ability.

Best regards.
Tony Clark
Application Developer
Kimball International.

---------------------------------------------------------------------------------------------------------------------------------------------------
Can someone verify that based on the next to last paragraph, automatic
redirects are not possible? However, the last paragraph points to the
fact that redirects are possible but the user agent could process it
incorrectly?

From: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
The description for 301 redirects is as follows:

10.3.2 301 Moved Permanently

The requested resource has been assigned a new permanent URI and any
future references to this resource SHOULD use one of the returned
URIs. Clients with link editing capabilities ought to automatically re-
link references to the Request-URI to one or more of the new
references returned by the server, where possible. This response is
cacheable unless indicated otherwise.

The new permanent URI SHOULD be given by the Location field in the
response. Unless the request method was HEAD, the entity of the
response SHOULD contain a short hypertext note with a hyperlink to the
new URI(s).

If the 301 status code is received in response to a request other than
GET or HEAD, the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.

Note: When automatically redirecting a POST request after
receiving a 301 status code, some existing HTTP/1.0 user agents
will erroneously change it into a GET request.
---------------------------------------------------------------------------------------------------------------------------------------------------

Mar 22 '07 #1
1 4761
You should set PreAuthenticate in true and use a CredentialsCache instead a
NetworkCredentials
Take a look to the following article:
http://msdn2.microsoft.com/en-us/library/aa302390.aspx
"pmasclark" <To**********@gmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
Hello,

I created a web site, site A, that redirects to another web site, site
B, where a simple web service is hosted. The code to call the web
service is simple.

oWS.AllowAutoRedirect = True
oWS.Credentials = New
System.Net.NetworkCredential("user","pass")
str = oWS.HelloWorld("World")

When I set the URI of the webservice to site B an http trace shows the
following.
POST 401 text/html http://siteB/redirect_test/service.asmx
POST 401 text/html http://siteB/redirect_test/service.asmx
POST 200 text/xml http://siteB/redirect_test/service.asmx

The result of the call
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"
xmlns:xsd="http://www.w3.org/2001/
XMLSchema">
<soap:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>Hello World</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>

When I try to test the redirect from site A to site B, I get the
following trace.
POST 301 text/html http://siteA/redirect_test/service.asmx
http://siteB/redirect_test/service.asmx
GET 401 text/html http://siteB/redirect_test/service.asmx
GET 401 text/html http://siteB/redirect_test/service.asmx
GET 200 text/html http://siteB/redirect_test/service.asmx

The result of this call is too long to post and be meaning full, but
the content is the list of methods for the web service. I am sure
most of you are familiar with the html rendering of the .asmx page
that lists the methods.

In both traces you will see 2 lines containing a 401. You can be
assured that security is not an issue. The 401's are a result of the
handshake that takes place to ensure that the user is valid.

The issue appears to be that the initial POST is getting changed to a
GET during the redirect. Thus the post stream that contains my SOAP
envelope is stripped and not sent to the web service at the new site.

If anyone has any ideas on why this may be happening and the best
method for resolving this issue I would greatly appreciate it.

This has been tested using web services hosted on IIS 6.0 and SAP
Netweaver 2004 & SAP ECC 5.0. The calling application was written
using VB.net in Visual Studio 2005. The .net framework version is 2.0
and the useragent string for the calling application is Mozilla/4.0
(compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.42).

If you need any more information about the environment or the calls
being made. Do not hesitate to post them and I will answer them to
the best of my ability.

Best regards.
Tony Clark
Application Developer
Kimball International.

---------------------------------------------------------------------------------------------------------------------------------------------------
Can someone verify that based on the next to last paragraph, automatic
redirects are not possible? However, the last paragraph points to the
fact that redirects are possible but the user agent could process it
incorrectly?

From: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
The description for 301 redirects is as follows:

10.3.2 301 Moved Permanently

The requested resource has been assigned a new permanent URI and any
future references to this resource SHOULD use one of the returned
URIs. Clients with link editing capabilities ought to automatically re-
link references to the Request-URI to one or more of the new
references returned by the server, where possible. This response is
cacheable unless indicated otherwise.

The new permanent URI SHOULD be given by the Location field in the
response. Unless the request method was HEAD, the entity of the
response SHOULD contain a short hypertext note with a hyperlink to the
new URI(s).

If the 301 status code is received in response to a request other than
GET or HEAD, the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.

Note: When automatically redirecting a POST request after
receiving a 301 status code, some existing HTTP/1.0 user agents
will erroneously change it into a GET request.
---------------------------------------------------------------------------------------------------------------------------------------------------
Mar 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Elijah | last post by:
My objective is to send a SOAP formatted request to a web method hosted by the M.S. TerraServer. I use the HTTP Post method. I also use the HttpWebRequest object to build the request. The problem...
4
by: Mark | last post by:
i have a very simple web servive Imports System.Web.Services <System.Web.Services.WebService(Namespace:="urn:Example1")> _ Public Class Example1 Inherits System.Web.Services.WebService
0
by: Michael Jackson | last post by:
I have attempted to mark up a service and it's methods so that it doesn't require the SOAPAction HTTP header to resolve the methods being called, this is done from first element in <SOAP-ENV:Body>...
2
by: Paul Hale | last post by:
I have a vb.net web service and client that are both working fine. If someone wanted to consume our web service using .NET, no problem. Im a little confused on how non .NET clients would use the...
16
by: MR | last post by:
my soap messages to a remote site are failing. as far as i can tell the only differences between what my SOAP message looks liek and what they want are in the SOAP envelope SInce they don't have a...
2
by: furrypop | last post by:
Hi, I'm trying to get the Perl SOAP::Lite examples to work on a Windows PC, running Apache 2.2.4. Apache is definitely serving CGI scripts, as I've tested a dummy Hello World thing. I'm also...
0
by: SpreadTooThin | last post by:
Not sure if this is the appropriate place to ask a question about soap. If you think you know a better news group to discuss this please point me there. I wrote a UPnP Internet Gateway Device...
1
Plater
by: Plater | last post by:
I have a webservice that claims the following: SOAP 1.1 The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values. POST...
2
by: Leafy | last post by:
Hi Folks! I sure hope someone can guide me on this issue. Here is the XML document I'm working from (nda.xml): <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.