Modify a Web Service's WSDL Using a SoapExtension

I ran the C# code in DeveloperFusions converter, then I made some modification to make it work. (http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx)
This is the HttpsReflector class:
VB.NET:
Imports System 
Imports System.Web.Services.Description 
Namespace Msdn.Web.Services.Samples 
Public Class HttpsReflector 
Inherits SoapExtensionReflector 
Public Overloads Overrides Sub ReflectMethod() 
End Sub 
Public Overloads Overrides Sub ReflectDescription() 
Dim description As ServiceDescription = ReflectionContext.ServiceDescription 
For Each service As System.Web.Services.Description.Service In description.Services
For Each port As Port In service.Ports
For Each extension As ServiceDescriptionFormatExtension In port.Extensions
Dim binding As SoapAddressBinding = CType(extension, SoapAddressBinding)
If Not binding Is Nothing Then
binding.Location = binding.Location.Replace("http://", "https://")
End If
Next
Next
Next
End Sub 
End Class 
End Namespace
And the rest to make it work:
Using Visual Studio 2005, I created the class above and put it in the App_Code folder in my web site. Then, in the web.config file, I added the following section within configuration/system.web:
HTML:
<webServices>
<soapExtensionReflectorTypes>
<add type="Msdn.Web.Services.Samples.HttpsReflector, App_code"/>
</soapExtensionReflectorTypes>
</webServices>
I didn't try the SSL certificate thing as described in MSDN "HOW TO: Secure XML Web Services with Secure Socket Layer in Windows Server 2003" http://support.microsoft.com/default.aspx?scid=kb;en-us;324284 ,but the web service address in the wdsl description displays https as intended.
 
Hi JohnH.

Thankyou for your reply!

When adding the ReflectorExtension class to the web.config file i'm getting this error; "The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'App_code' or one of its dependencies." Ending with the project not being able to compile.

Is it possible for you to mail your project to me, it would be highly appriciated!
 
You just didn't follow the instructions about putting the class file in App_code folder. Add a new class in the App_code folder and paste the VB.Net code above into it. It is the HttpsReflector class and the type instruction above tells the service that it can be found in the App_code folder.
 
Back
Top