Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Go Back  Xtreme Visual Basic Talk > > > Dynamic Web Service discovery and validation


Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2005, 09:03 AM
ZuluWarrior's Avatar
ZuluWarrior ZuluWarrior is offline
Centurion
 
Join Date: Feb 2004
Posts: 136
Default Dynamic Web Service discovery and validation


Hi all!

I am creating an application that communicates to a web service and recieves data from the service via 4 methods. The application has a list of multiple download sources within it's configuration file.

I have a web reference (and auto-genorated proxy class) within my application. Setting the URL of this at run time is relatively easy. However validating that this reference works and that all the proxy's methods are supported by the Web Service is another matter.

The below code will change the URL of the WebService reference and validate that it resides in the correct namespace (according to the namespace origionally discovered by the visual studio "Add Web Reference" macros.

Code:
Dim Service As New TestService.MyService
Service.Url = "http://www.mywebsite.com/MyTestService.asmx"
Service.Discover()
This code will throw an exception if the namespace of the service pointed to by the new Url is not the same as the Proxy's namespace. However, If the namespace is the same on the Web Service but (for instance) one of the methods is missing an exception is not thrown until the method is called.

What I am after is a way of checking or retrieving the exposed methods at the point where I 'discover' the new Url, without necessarily executing (or Invoking) them.

Another problem is that you can't use the GetType function as this returns a type of the Proxy class, which still has the same static methods (even if they point to a function that no longer exists.

Anyone have any Ideas?? I was looking also at the ServiceDescription namespace but there does not seem to be anything in there that is relevent...

Please HELP!!!

Thanks in Advance ZuluWarrior
Reply With Quote
  #2  
Old 10-20-2005, 09:25 AM
ZuluWarrior's Avatar
ZuluWarrior ZuluWarrior is offline
Centurion
 
Join Date: Feb 2004
Posts: 136
Default Further information

So that everyone can understand what I am trying to do, here is some example code.


First, Here is a web service, lets say that it is hosted at "http://www.testsite.com/services/service1.asmx"
Code:
Imports System.Web.Services

<System.Web.Services.WebService(Namespace:="http://www.testsite.com/Services/Service1")> _
Public Class Service1
    Inherits System.Web.Services.WebService

#Region " Web Services Designer Generated Code "
' ... (trimmed)
#End Region

    <WebMethod()> _
    Public Function Method1() As String
      Return "(1)Hello from Method 1"
    End Function

    <WebMethod()> _
    Public Function Method2() As String
      Return "(1)And greetings from Method 2"
    End Function

End Class
Next, here is another similar webservice, although this one has a method missing. Note that it has the same namespace. Lets say that this one is hosted at "http://www.mybackupsite.com/services/service1.asmx"
Code:
Imports System.Web.Services

<System.Web.Services.WebService(Namespace:="http://www.testsite.com/Services/Service1")> _
Public Class Service1
    Inherits System.Web.Services.WebService

#Region " Web Services Designer Generated Code "
' ... (trimmed)
#End Region

    <WebMethod()> _
    Public Function Method1() As String
      Return "(2)Hello from Method 1"
    End Function

End Class
Now, finally here is a sub that is residing in my application (a VB.Net Windows App). The Origional web service was referenced and discovered by VS.NET and resides in the namespace "TestService".
Code:
Private Sub FindWorkingHost(HostList() as String)
  Dim WorkingHost As Boolean = False
  Dim Service As New TestService.Service1
  Dim C As Integer = 0

  Do Until WorkingHost 
    Try
      Service.Url = HostList(C)
      Service.Discover()
      'INSERT METHOD VALIDATION HERE
      WorkingHost = True
    Catch ex As Exception
      WorkingHost = False
    Finally
      C += 1
    End Try
  Loop
End Sub
As you can see, the above snippet takes a list of Host Url addresses (HostList() )
Code:
Dim HostList(1) As String
HostList(0) = "http://www.mybackupsite.com/services/service1.asmx"
HostList(1) = "http://www.testsite.com/services/service1.asmx"
Within the loop, each address is applied to the URL property. The service is discovered (this checks that the service's namespace is corrent), and throws an exception if not. If discovery works, the loop is exited.

The problem is that the discovery works for the first address, even though a method is missing! And it is not until I call that method that an exception is thrown, as this call can happen after alot of programming (and indeed other webmethods) have executed, this will not do. I need a mechanism whereby I can check that all the methods within the proxy exist (and as an added extra, that the parameters and returns are the same) at the point where my comment ('INSERT METHOD VALIDATION HERE) is.

Any Ideas, anyone??

Guru's, I'm looking at you!

Thanks,

ZuluWarrior
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
 
Dynamic Web Service discovery and validation
Dynamic Web Service discovery and validation
 
-->