C# webservice async callback not getting called on HTTP 407 error.

Posted by Ben on Stack Overflow See other posts from Stack Overflow or by Ben
Published on 2010-04-30T18:05:37Z Indexed on 2010/05/03 17:58 UTC
Read the original article Hit count: 315

Filed under:
|
|
|
|

Hi,

I am trying to test the use-case of a customer having a proxy with login credentials, trying to use our webservice from our client.

If the request is synchronous, my job is easy. Catch the WebException, check for the 407 code, and prompt the user for the login credentials.

However, for async requests, I seem to be running into a problem: the callback is never getting called! I ran a wireshark trace and did indeed see that the HTTP 407 error was being passed back, so I am bewildered as to what to do.

Here is the code that sets up the callback and starts the request:

TravelService.TravelServiceImplService svc = new TravelService.TravelServiceImplService();
svc.Url = svcUrl;
svc.CreateEventCompleted += CbkCreateEventCompleted;
svc.CreateEventAsync(crReq, req);

And the code that was generated when I consumed the WSDL:

public void CreateEventAsync(TravelServiceCreateEventRequest CreateEventRequest, object userState) {
        if ((this.CreateEventOperationCompleted == null)) {
            this.CreateEventOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateEventOperationCompleted);
        }

        this.InvokeAsync("CreateEvent", new object[] {
                    CreateEventRequest}, this.CreateEventOperationCompleted, userState);
    }

    private void OnCreateEventOperationCompleted(object arg) {
        if ((this.CreateEventCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.CreateEventCompleted(this, new CreateEventCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

Debugging the WS code, I found that even the SoapHttpClientProtocol.InvokeAsync method was not calling its callback as well. Am I missing some sort of configuration?

© Stack Overflow or respective owner

Related posts about c#

Related posts about webservice