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;

}

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.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345