|
Resolving .NET System.Web Namespace Manually
Well, there is unresolved namespace for the IHttpModule interface although we already imported the System.web namespace.
This issue can be verified through the References page of the project property.
|
There is no System.Web namespace. So we need to add it manually.
Select the AsyncModuleVB project folder > Right-click mouse > Select Add Reference menu.
Find and select the System.Web component and click OK. The IHttpModule interface should be resolved.
Next we need to add a reference to the web service created earlier or normally called a proxy class. However, the new implementation is using the event based reference which does not provide the BeginXXX and EndXXX methods anymore. In order to use the BeginXXX and EndXXX we need to modify the project property before adding the web service reference. This is based on this Microsoft fuckback.
Firstly we need to unload the project or close the solution. Then, open the project file, AsyncModuleVB.vbproj file in any unformatted text editor.
Add the following property setting inside the <PropertyGroup> and save the project file.
<WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>
Then, reopen the solution. Select the project folder > Right-click mouse > Select Add Service Reference menu.
In the Add Service Reference, click the Advanced button.
In the Service Reference Settings page, click the Add Web Reference button. We are going to add a web service in this case.
In the Add Web Reference page, click the first link, Web Services in this solution.
Then, click the Service1 link.
The exposed web service methods will be displayed. You can test the exposed methods as done previously.
Rename the web reference from localhost to AuthorizationService and click the Web Reference button.
The web service reference or proxy class should be visible in the Solution Explorer.
|
|
You can view the auto generated proxy class file under the Web References folder in the project folder.
The following is the proxy class file (Reference.vb) content. There are also WSDL file which provide the definition for the web service, the map and discovery files. The discovery file used for the web service 'advertisement'.
'------------------------------------------------------------------------------ ' <auto-generated> ' This code was generated by a tool. ' Runtime Version:2.0.50727.3053 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </auto-generated> '------------------------------------------------------------------------------
Option Strict Off Option Explicit On
Imports System Imports System.ComponentModel Imports System.Diagnostics Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Xml.Serialization
' 'This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.3053.
Namespace AuthorizationService
'''<remarks/> <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053"), _ System.Diagnostics.DebuggerStepThroughAttribute(), _ System.ComponentModel.DesignerCategoryAttribute("code"), _ System.Web.Services.WebServiceBindingAttribute(Name:="Service1Soap", [Namespace]:="http://tempuri.org/")> _ Partial Public Class Service1 Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
Private SumOperationCompleted As System.Threading.SendOrPostCallback Private IsAuthorizedOperationCompleted As System.Threading.SendOrPostCallback Private useDefaultCredentialsSetExplicitly As Boolean
'''<remarks/> Public Sub New() MyBase.New Me.Url = Global.AsyncModuleVB.My.MySettings.Default.AsyncModuleVB_AuthorizationService_Service1 If (Me.IsLocalFileSystemWebService(Me.Url) = true) Then Me.UseDefaultCredentials = true Me.useDefaultCredentialsSetExplicitly = false Else Me.useDefaultCredentialsSetExplicitly = true End If End Sub
Public Shadows Property Url() As String Get Return MyBase.Url End Get Set If (((Me.IsLocalFileSystemWebService(MyBase.Url) = true) _ AndAlso (Me.useDefaultCredentialsSetExplicitly = false)) _ AndAlso (Me.IsLocalFileSystemWebService(value) = false)) Then MyBase.UseDefaultCredentials = false End If MyBase.Url = value End Set End Property
Public Shadows Property UseDefaultCredentials() As Boolean Get Return MyBase.UseDefaultCredentials End Get Set MyBase.UseDefaultCredentials = value Me.useDefaultCredentialsSetExplicitly = true End Set End Property
'''<remarks/> Public Event SumCompleted As SumCompletedEventHandler
'''<remarks/> Public Event IsAuthorizedCompleted As IsAuthorizedCompletedEventHandler
'''<remarks/> <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Sum", RequestNamespace:="http://tempuri.org/", ResponseNamespace:="http://tempuri.org/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _ Public Function Sum(ByVal lhs As Integer, ByVal rhs As Integer) As Integer Dim results() As Object = Me.Invoke("Sum", New Object() {lhs, rhs}) Return CType(results(0),Integer) End Function
'''<remarks/> Public Function BeginSum(ByVal lhs As Integer, ByVal rhs As Integer, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult Return Me.BeginInvoke("Sum", New Object() {lhs, rhs}, callback, asyncState) End Function
'''<remarks/> Public Function EndSum(ByVal asyncResult As System.IAsyncResult) As Integer Dim results() As Object = Me.EndInvoke(asyncResult) Return CType(results(0),Integer) End Function
'''<remarks/> Public Overloads Sub SumAsync(ByVal lhs As Integer, ByVal rhs As Integer) Me.SumAsync(lhs, rhs, Nothing) End Sub
'''<remarks/> Public Overloads Sub SumAsync(ByVal lhs As Integer, ByVal rhs As Integer, ByVal userState As Object) If (Me.SumOperationCompleted Is Nothing) Then Me.SumOperationCompleted = AddressOf Me.OnSumOperationCompleted End If Me.InvokeAsync("Sum", New Object() {lhs, rhs}, Me.SumOperationCompleted, userState) End Sub
Private Sub OnSumOperationCompleted(ByVal arg As Object) If (Not (Me.SumCompletedEvent) Is Nothing) Then Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs) RaiseEvent SumCompleted(Me, New SumCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)) End If End Sub
'''<remarks/> <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/IsAuthorized", RequestNamespace:="http://tempuri.org/", ResponseNamespace:="http://tempuri.org/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _ Public Function IsAuthorized(ByVal userName As String) As Boolean Dim results() As Object = Me.Invoke("IsAuthorized", New Object() {userName}) Return CType(results(0),Boolean) End Function
'''<remarks/> Public Function BeginIsAuthorized(ByVal userName As String, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult Return Me.BeginInvoke("IsAuthorized", New Object() {userName}, callback, asyncState) End Function
'''<remarks/> Public Function EndIsAuthorized(ByVal asyncResult As System.IAsyncResult) As Boolean Dim results() As Object = Me.EndInvoke(asyncResult) Return CType(results(0),Boolean) End Function
'''<remarks/> Public Overloads Sub IsAuthorizedAsync(ByVal userName As String) Me.IsAuthorizedAsync(userName, Nothing) End Sub
'''<remarks/> Public Overloads Sub IsAuthorizedAsync(ByVal userName As String, ByVal userState As Object) If (Me.IsAuthorizedOperationCompleted Is Nothing) Then Me.IsAuthorizedOperationCompleted = AddressOf Me.OnIsAuthorizedOperationCompleted End If Me.InvokeAsync("IsAuthorized", New Object() {userName}, Me.IsAuthorizedOperationCompleted, userState) End Sub
Private Sub OnIsAuthorizedOperationCompleted(ByVal arg As Object) If (Not (Me.IsAuthorizedCompletedEvent) Is Nothing) Then Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs) RaiseEvent IsAuthorizedCompleted(Me, New IsAuthorizedCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)) End If End Sub
'''<remarks/> Public Shadows Sub CancelAsync(ByVal userState As Object) MyBase.CancelAsync(userState) End Sub
Private Function IsLocalFileSystemWebService(ByVal url As String) As Boolean If ((url Is Nothing) _ OrElse (url Is String.Empty)) Then Return false End If Dim wsUri As System.Uri = New System.Uri(url) If ((wsUri.Port >= 1024) _ AndAlso (String.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) = 0)) Then Return true End If Return false End Function End Class
'''<remarks/> <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")> _ Public Delegate Sub SumCompletedEventHandler(ByVal sender As Object, ByVal e As SumCompletedEventArgs)
'''<remarks/> <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053"), _ System.Diagnostics.DebuggerStepThroughAttribute(), _ System.ComponentModel.DesignerCategoryAttribute("code")> _ Partial Public Class SumCompletedEventArgs Inherits System.ComponentModel.AsyncCompletedEventArgs
Private results() As Object
Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) MyBase.New(exception, cancelled, userState) Me.results = results End Sub
'''<remarks/> Public ReadOnly Property Result() As Integer Get Me.RaiseExceptionIfNecessary Return CType(Me.results(0),Integer) End Get End Property End Class
'''<remarks/> <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")> _ Public Delegate Sub IsAuthorizedCompletedEventHandler(ByVal sender As Object, ByVal e As IsAuthorizedCompletedEventArgs)
'''<remarks/> <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053"), _ System.Diagnostics.DebuggerStepThroughAttribute(), _ System.ComponentModel.DesignerCategoryAttribute("code")> _ Partial Public Class IsAuthorizedCompletedEventArgs Inherits System.ComponentModel.AsyncCompletedEventArgs
Private results() As Object
Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) MyBase.New(exception, cancelled, userState) Me.results = results End Sub
'''<remarks/> Public ReadOnly Property Result() As Boolean Get Me.RaiseExceptionIfNecessary Return CType(Me.results(0),Boolean) End Get End Property End Class End Namespace |
The following Figure is the screenshot for the auto generated proxy class. You can edit the content however, when the reference is re-generated, the modification will be lost.