[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 564
  • Last Modified:

vb.net web service blocked by ISA server 407 error

*        I have a web service all up and working in my vb-dot-net code, talking from my XP laptop to my web server - no problem.
*        Internally all is well and from home to work all is fine also.
*        In the weekend I attempted to install the program on PC’s at a clients site, this is when the problem started – they have an ISA server with user authenticate turned on –my  web service will no longer talk to the web server.

Every time the program runs the following turns up in the ISA web log and the program does not work (Ip addresses and names changed to protect the innocent - ha ha).

NOTE: Microsoft ISA Server 2000 Version 3.0.1200.166 SP1
          Developing with Microsoft visual studio .net 2003

169.4.0.171   anonymous  Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 1.1.4322.573)          2005-04-09    04:01:28       XXXXISA       -        123.124.125.126          -        80      -        374          4550   http    POST  http://123.124.125.126/WXRwebclientservices/WXRwebclientservices.asmx         -          407

From what I have ‘googled’ - The 407 at the end indicates that my web service need to authenticate to get through the ISA web.  

Now for some code…..

‘    Initially I had the following (the web service returns a string to the client):

Dim wWXRwebserviceswebref As New WXRwebservices.WXRwebservices
wWXRwebserviceswebref.Timeout = 15000 ' in milliseconds (15 seconds)
‘ (by the way the web services still takes longer than 15 seconds to time out - ideas anyone)

Dim wAction as string = “”

Try
  wAction = wWXRWebClientServicesRef.WinXRay(wWXRsid)
catch ex as exception
end try

‘         This worked great for my pc at home
‘         At the client with the ISA server on and the error above I ‘googled’ and found this to try

Try
  wAction = wWXRWebClientServicesRef.WinXRay(wWXRsid)
catch ex as exception
   try    
      Dim wMyCredentials As New System.Net.CredentialCache
      Dim wNetCred As New NetworkCredential(“login", "password")
      wMyCredentials.Add(New Uri(wWXRwebserviceswebref.Url), "Basic", wNetCred)
      wWXRwebserviceswebref.Credentials = wMyCredentials
      wAction = wWXRWebClientServicesRef.WinXRay(wWXRsid)
   catch ex2 as exception
   end try                
end try

‘ This had no improvement, still an anonymous failure in the ISA log!.

‘   What is the story with the “Basic” in the credentials example above also, are there a number of other options I should try like encrypted or something? – I am happy to have a number of ‘try’, exceptions in my code to eventually talk to the web service?
‘ I have tried adding the proxy settings picked up from the users explorer settings out of the registry i.e http://169.4.0.11:8080/ - I am not sure if I need to do this but have tried with and without these settings – same ISA error  i.e - wWXRWebClientServicesRef.Proxy = New System.Net.WebProxy("http://169.4.0.11:8080/")

All help would be most appreciated

Cheers

Karl Spurling
Auckland
New Zealand
 
0
kxs
Asked:
kxs
  • 2
1 Solution
 
heintalusCommented:
Hi Karl

From memory you need to add the credentials to your new WebProxy & then set your web service reference to use this new proxy, something like the following, you might also need to include the Domain in your network credentials

Dim tmpproxy As WebProxy
tmpproxy =  New System.Net.WebProxy("http://169.4.0.11",8080)
tmpproxy.Credentials = New NetworkCredential(“login", "password")    'You might also need the domain here
wWXRwebserviceswebref.Proxy = tmpproxy
wAction = wWXRWebClientServicesRef.WinXRay(wWXRsid)

I'm not at my development machine at the moment so cant be sure of the above syntax, but this might get you going

HTH
Andy
Also from Auckland, New Zealand
0
 
kxsAuthor Commented:
Thanks Andy,

I would like to pick up the default credentials from the cache and not have to either prompt the user for a login and password or hard code one into the application.

Last night I tried the following again resulting in a 407 error in the ISA log?

            '
            ' Add the User Credentials and try that
            '
            wRegHkcu = Registry.CurrentUser
            wRegKey = wRegHkcu.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", False)
            If Not IsNothing(wRegKey) AndAlso Not IsNothing(wRegKey.GetValue("ProxyEnable")) Then
                If wRegKey.GetValue("ProxyEnable") = 1 Then
                    If Not IsNothing(wRegKey.GetValue("ProxyServer")) Then
                        Dim wYourWebProxy As String = "h" & "ttp://" & wRegKey.GetValue("ProxyServer") & "/"
                        wWXRWebClientServicesRef.Proxy = New System.Net.WebProxy(wYourWebProxy)
                        wWXRWebClientProxy = wYourWebProxy
                    End If
                End If
            End If
            wTmpProxy.Credentials = wMyCredentials.DefaultCredentials
            wWXRWebClientServicesRef.Proxy = wTmpProxy
            Try
                wAction = wWXRWebClientServicesRef.WinXRay(wWXRsid)
            Catch ex As Exception
            End Try


Any further comments would be appreciated, as always I am looking for the 'silver bullet' code to access the web service from all firewalls.

Go the Bluse, the Black Caps, the Warriors, the All Blacks and Lion Red - ha ha

Cheers

Karl
0
 
heintalusCommented:
Hi Karl

Try changing this line

wTmpProxy.Credentials = wMyCredentials.DefaultCredentials

to

wTmpProxy.Credentials = System.Net.CredentialCache.DefaultCredentials

If this doesn't work then you might need to explicitly configure your ISA server to allow access to that website on port 8080, you should be able to confirm this by entering the URL in your webbrowser & seeing if you can get to it from there.
i.e. http://123.124.125.126/WXRwebclientservices/WXRwebclientservices.asmx:8080

If you need info on configuring ISA server then a good site is www.isaserver.org

HTH
Andy
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now