Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:40:29+00:00 2026-05-30T14:40:29+00:00

I have a WCF Service as a proxy that calls a WebClient to return

  • 0

I have a WCF Service as a proxy that calls a WebClient to return a string. The WebClient is querying a Token service where the user name and password is sent via https. The service works fine if the Username and Password is correct however if the username and password are invalid the WebClient throws an exception (403 Forbidden) which is expected and handled in the code below. however the WCF service then proceeds to hang until it times out which i cant figure out why.

Public Function GetToken(un As String, pw As String, ref As String) As TokenResult Implements IAGSAuthentication.GetToken

        Dim Token As String
        Dim TokenURL As String = String.Format("https://server/arcgisserver/tokens?request=getToken&username={0}&password={1}&timeout={2}", un, pw, Timeout)
        Dim tokenResult As TokenResult = New TokenResult
        If TokenService.IsBusy = False Then

            Try
                Token = TokenService.DownloadString(New Uri(TokenURL))
                tokenResult.Token = Token
                Return tokenResult
                Exit Function
            Catch ANEx As ArgumentNullException
                TokenService.Dispose()
                tokenResult.TokenException = ANEx
                Return tokenResult
                Exit Function
            Catch WEx As WebException
                TokenService.Dispose()
                tokenResult.TokenException = WEx
                Return tokenResult
                Exit Function
            Catch CEx As CommunicationException
                TokenService.Dispose()
                tokenResult.TokenException = CEx
                Return tokenResult
                Exit Function
            Catch Ex As Exception
                TokenService.Dispose()
                tokenResult.TokenException = Ex
                Return tokenResult
                Exit Function
            End Try

        End If
        Return tokenResult
    End Function

I should also add that when im debugging the WCF Reference file shows me an exception at a auto populated clientside method.

Public Function EndGetToken(ByVal result As System.IAsyncResult) As AuthServiceRef.TokenResult Implements AuthServiceRef.AuthService.EndGetToken
                Dim _args((0) - 1) As Object
                Dim _result As AuthServiceRef.TokenResult = CType(MyBase.EndInvoke("GetToken", _args, result),AuthServiceRef.TokenResult)
                Return _result
            End Function

I thing is is that I thought that by handling the exception in the WCF service and returning the exception inside the custom class that I could push the exception up to the user without and runtime issues. Here is the Exception caught client side:

System.ServiceModel.CommunicationException was unhandled by user code

Message=The remote server returned an error: NotFound.
StackTrace:
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase1.ChannelBase1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at MatrixWebMap.AuthServiceRef.AuthServiceClient.AuthServiceClientChannel.EndGetToken(IAsyncResult result)
at MatrixWebMap.AuthServiceRef.AuthServiceClient.AuthServiceRef_AuthService_EndGetToken(IAsyncResult result)
at MatrixWebMap.AuthServiceRef.AuthServiceClient.OnEndGetToken(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
InnerException: System.Net.WebException
Message=The remote server returned an error: NotFound.
StackTrace:
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
InnerException: System.Net.WebException
Message=The remote server returned an error: NotFound.
StackTrace:
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c_DisplayClassa.b_9(Object sendState)
at System.Net.Browser.AsyncHelper.<>c_DisplayClass4.b_0(Object sendState)
InnerException:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:40:30+00:00Added an answer on May 30, 2026 at 2:40 pm

    So, from what I gather when i add the exception to the TokenResult class and return it, the WCF response had a problem with the exception property. The work around was to deal with the exception before the response and make the TokenException a string that is created before returing the result.

    So, for a ‘403 Forbidden’ web exception i simply constructed a string and returned “”The information you have entered does not match our records. Please try again.” Kind of a dirty work around but its perfectly appropriate for what im trying to do here.

                Try
                    Token = TokenService.DownloadString(New Uri(TokenURL))
                    tokenResult.Token = Token
                    Return tokenResult
                    Exit Function
    
                Catch ANEx As ArgumentNullException                
                    tokenResult.TokenException = ANEx.Message
                    Return tokenResult
                    Exit Function
    
                Catch WEx As WebException                   
                    If WEx.Status = WebExceptionStatus.ProtocolError Then
                        tokenResult.TokenException = "The information you have entered does not match our records. Please try again."
                    Else
                        tokenResult.TokenException = WEx.Message
                    End If
                    Return tokenResult
                    Exit Function
    
                Catch CEx As CommunicationException      
                    tokenResult.TokenException = CEx.Message
                    Return tokenResult
                    Exit Function
    
                Catch Ex As Exception                    
                    tokenResult.TokenException = Ex.Message
                    Return tokenResult
                    Exit Function
                End Try
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF Service that requires a security token issued by a separate
I have a WCF service that I have to reference from a .net 2.0
I have a WCF service, hosted in IIS 7.0 that needs to run database
I have a WCF service with the following configuration: <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name=MetadataEnabled>
I have a WCF Service that should not enter the faulted state. If there's
I have a WCF service that is hosted in a windows application. The service
I have a WCF service that needs to know the Principal of the calling
here's the setup for the project. I have a WCF Service that is hosted
I am currently trying to create a REST proxy that calls a WCF SOAP
I have a WCF service that passes back and forth the following DataContracts: [DataContract]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.