views:

229

answers:

2

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?

A: 

I later found out that the problem was with my proxy server, and not the code. Switching to a different proxy server, as well as NOT testing with basic auth (who uses it anyway?), I was able to get my callbacks.

Ben
A: 

I had the same issue. Now I just instantiate a timer and go to my disconnected state in there.

DarkFader