Specify Expect100Continue=false in Web Service client.

The Web Service Provider that we are using recommends NOT send Expect100Continue header.
The specifying static value
System.Net.ServicePointManager.Expect100Continue=false;
is not good, because some other providers may prefer to use the header.
In the haacked's "HttpWebRequest and the Expect: 100-continue Header Problem" post   comment of Mirronelli Jun 02, 2005 6:22 AM  suggest to specify webRequest.ServicePoint.Expect100Continue = false; for  each webRequest.

 If I am using web service(derived from SoapHttpClientProtocol) I can use ServicePointManager Class FindServicePoint method. 

Uri uri=new Uri(xws.Url);
ServicePoint servicePoint = ServicePointManager.FindServicePoint(uri);
// Debug.Assert(servicePoint.Expect100Continue == false, "Investigate why not?.");
if (servicePoint.Expect100Continue == true)
{ //should happen only once for each URL
   servicePoint.Expect100Continue =
false;

}

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted @ Tuesday, January 13, 2009 11:47 PM
Print

Comments on this entry:

# re: Specify Expect100Continue=false in Web Service client.

Left by lixid at 3/23/2009 2:35 AM
Gravatar
This was a serious life saver. Seriously thank you. I had been troubleshooting this for roughly 8 hours straight and couldn't find a solution and came across the comment by Mirronelli and tried that and it wasn't working. I kept getting a null exception but with this code it doesn't do that now. Thanks you again.

# re: Specify Expect100Continue=false in Web Service client.

Left by Dejan Stanic at 12/10/2009 6:38 AM
Gravatar
Thanks.
This was of great help.

# re: Specify Expect100Continue=false in Web Service client.

Left by Günger Zöchbauer at 1/6/2010 3:11 PM
Gravatar
Thanks.
Great time saver.

# Expect100Continue - How to Send Data Packet

Left by Anil Kumar at 6/1/2010 4:25 AM
Gravatar
It's OK i am getting Expect100Continue Error, now how to send data bytes in Next Continue Packet to complete the request.

2. OK, i disabled Expect100Continue=false, but sniffer shows it sending 2 request 2 server, 1 without Post Data and 1 with Post Data, whereas 1st Request which goes without Post Data get Response Returned, however 2nd Request just gone, thought it's in correct form, but getting no response.

# re: Specify Expect100Continue=false in Web Service client.

Left by Arne at 9/9/2010 4:43 AM
Gravatar
Great tip!
But, after a while my SOAP client goes back to the default value Expect100Continue=true...? Any ideas?

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910