How do I implement async SOAP calls in a client application?

105 views Asked by At

I have been working on a project where I get data from a database using SOAP functions.

Initially, I loaded the .wsdl file from the development version of the database into Visual Studio as a Service Reference

using ServRef = MyApp.DBServiceReference;

and was able to retrieve single entries from the soap call

    ServRef.FBTservice fbtService = new ServRef.FBTservice();
    ServRef.BugStruct singleBug = fbtService.getId(uniqueBugId, username, password);

as well get an entire list of issues

    ServRef.FBTservice fbtService = new ServRef.FBTservice();
    ServRef.FilterStruct filter = new ServRef.FilterStruct();
    filter.mColumn = new string[] { "1", "3", "12" };
    ServRef.BugStruct[] bugArr = fbtService.getBugList(filter, username, password);

This method works fine for our development database, but because our production version requires authentication through an access manager, I had to find a different method.

To get this to work for our production environment, I needed to find a way to authenticate with the access manager, collect the cookies from authentication process, then attach these cookies to my SOAP call.

I was unable to do this with my Service Reference, but found that by loading my .wsdl as a Web Reference instead of a Service Reference,

using WebRef = MyApp.DBWebReference;

I could attach my cookies and grab a list of issues from the production version, like so

    WebRef.FBTservice fbtService = new WebRef.FBTservice();
    fbtService.CookieContainer = this.authCookieContainer;
    WebRef.FilterStruct filter = new WebRef.FilterStruct();
    filter.mColumn = new string[] { "1", "3", "12" };
    WebRef.BugStruct[] bugArr = fbtService.getBugList(filter, username, password);

Now, to my issue/question. When I loaded my .wsdl as a Web Reference, I seemed to have access to some more methods and variables, namely getBugListAsync() and getBugAsync(). Here are the relevant objects from the Web Reference that I got from looking in the Object Browser:

public void getBugListAsync(FilterStruct filterStruct, string loginid, string password)
public void getBugListAsync(FilterStruct filterStruct, string loginid, string password, object userState)

private void OngetBugListOperationCompleted(object arg)

private System.Threading.SendOrPostCallback getBugListOperationCompleted
public event getBugListCompletedEventHandler getBugListCompleted

How would I go about implementing these calls? I have worked with events and event handlers, but only to the extent of researching online how to handle simple events, and using the examples to guide me through it.

0

There are 0 answers