in

Paul Rausch

Overriding the default generated WSDL on a service

I recently came across a scenario where I needed to use a flash component that consumed a web service on a project.  I had no control over the flash as it was written by a 3rd party.  Anyway the problem was the application was hosted on a load balanced configuration and when the flash would pull the WSDL definition (within the same application no less) an internal port number was appended to the service location( http://www.sitedomain.com:xxxx/app/service.asmx).   The problem was the client flash could not access that url, so what I ended up doing was overriding the wsdl generation and manually stripping out the port number.  The following code needs to be built into the web service application. Imports System
Imports System.Web.Services.Description

Public Class WSDLCustomGenerator Inherits SoapExtensionReflector

Public Overrides Sub ReflectMethod()

        Dim description As ServiceDescription = ReflectionContext.ServiceDescription
       
Dim serv As System.Web.Services.Description.Service

        For Each serv In description.Services
           
Dim pt As Port

            For Each pt In serv.Ports
                 Dim ext As ServiceDescriptionFormatExtension 
                 
                 For Each ext In pt.Extensions
                     
Dim binding As SoapAddressBinding
                      binding = CType(ext, SoapAddressBinding)

                      If Not binding Is Nothing Then
                          'Nice hacky way of testing for the :xxxx port after the url I'm assuming is 10 characters long, and shouldn't have a port number ever
                         
If binding.Location.IndexOf(":", 10) > 0 Then

                         'Replace port number
                         binding.Location = binding.Location.Remove(binding.Location.IndexOf(":", 10), 5)

                     End If
                
End If
              
Next
          
Next
       
Next
End Sub
End Class

Only published comments... Apr 14 2008, 01:06 PM by prausch
Filed under: , ,

Leave a Comment

(required)  
(optional)
(required)  
Add
Inetium, LLC. Disclaimer