Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: HTTP protocol error


Message #1 by "Tobias C. Cahoon" <tobias.cahoon@e...> on Fri, 1 Feb 2002 21:28:48
I am developing a VB.NET Client accesses a web service via the following 
code:

Imports System
Imports System.Diagnostics
Imports System.Net
Imports System.Security
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

' Proxy class
<System.Web.Services.WebServiceBindingAttribute( _
 Name:="soapClient", _
 [Namespace]:="urn:soapClient")> _
Public Class soapClient
    Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

    ' Hard-code userid and password - for testing
    Dim myCred As New NetworkCredential("user", "passwd")
    Dim myCache As New CredentialCache()

    ' Constructor: pass in user/app userid and passwd when creating new 
soapClient
    <System.Diagnostics.DebuggerStepThroughAttribute()> _
    Public Sub New()
        MyBase.New()
        ' HTTPS
        Me.Url = "https://"

        ' HTTP
        'Me.Url = "http://"

        myCache.Add(New Uri("https://"), "Basic", myCred)
        'myCache.Add(New Uri("http://"), "Basic", myCred)

        Me.Credentials = myCache
    End Sub

    ' Web service
    <System.Diagnostics.DebuggerStepThroughAttribute(), _
    System.Web.Services.Protocols.SoapDocumentMethodAttribute( _
     "urn:soapClient/echo", _
     RequestNamespace:="urn:Echo", _
     ResponseNamespace:="urn:soapClient", _
     Use:=System.Web.Services.Description.SoapBindingUse.Encoded, _
     ParameterStyle:= _
      System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
    Public Function echo(ByVal Name As String) As String
        Dim results() As Object = Me.Invoke("echo", New Object() {Name})
        Return CType(results(0), String)
    End Function

End Class

I have left out the URI on purpose. I can access the method over HTTP with 
and without authentication. I can also access the method over HTTPS 
without authentication, but when I try to access the method with 
authentication over HTTPS I get the following error message:

 An unhandled exception of type 'System.Net.WebException' occurred in 
system.web.services.dll

Additional information: The underlying connection was closed: The server 
committed an HTTP protocol violation.

I checked the server and it is throwing a SocketException: Socket Closed. 
It looks like the client sends a request twice; first without the 
password, and then with the userid and the password.

Does anybody have an idea on how to resolve this? Any help would be 
greatly appreciated.

Thanks,

Toby


  Return to Index