Expect: 100-Continue issue with WebClient Class in .Net 2.0.
We're using the WebClient Class (2.0.50727) to POST soap transactions to a Web Service which requires authentication.
It appears that the client is issuing the "Expect: 100-Continue" header correctly but then not appropriately handling the "100-Continue" response from the server (IIS 6).
The following code will reproduce the behavior:
Dim _WebClient asNew WebClient
_WebClient.Credentials =New NetworkCredential("User", "Password","Domain")
_WebClient.Headers.Add(HttpRequestHeader.UserAgent,"USERAGENTSTRING")
_WebClient.Headers.Add("SOAPAction", Chr(34) &http://tempURI.org/Command & Chr(34))
_WebClient.Headers.Add("Content-Type","text/xml; charset=utf-8")
_WebClient.UploadString(_Uri, _BodyData)
This request results in multiple data POST's to the web server. This behavior has reproduced itself in every configuration we've tried.
The network capture stream is included below.
- Client traffic is in Green
- Server traffic is in Blue
- The POST body of the first request (which to my knowledge shouldn't be sent until after the "100-Continue"
--
POST /path/to/file.php HTTP/1.1
SOAPAction: "http://tempURI.org/Command"
Content-Type: text/xml; charset=utf-8
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.832)
Host: XXX.XXX.XXX.XXX
Content-Length: 426
Expect: 100-continue
Connection: Keep-Alive
HTTP/1.1 401 Unauthorized
Content-Length: 1656
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Basic realm="XXX.XXX.XXX.XXX"
X-Powered-By: ASP.NET
Date: Wed, 01 Aug 2007 23:35:48 GMT
<HTML>*ERROR TEXT DELETED*</HTML>
<?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>
<command xmlns="http://tempURI.org/service">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
</command>
</soap:Body>
</soap:Envelope>
POST /path/to/file.php HTTP/1.1
SOAPAction: "http://tempURI.org/command"
Content-Type: text/xml; charset=utf-8
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.832)
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Host: XXX.XXX.XXX.XXX
Content-Length: 426
Expect: 100-continue
HTTP/1.1 100 Continue
<?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>
<command
</command>
</soap:Body>
</soap:Envelope>
--
