0

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.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
SimTrooper
  • 92
  • 8
  • 1
    You have solved your problem the wrong way. Instead of falling back to the legacy (i.e., unsupported) ASMX technology, you should simply have come here and asked how to attach your cookies to a WCF Service Reference. – John Saunders Jun 18 '15 at 16:17
  • I attempted to do that a while back [here](http://stackoverflow.com/questions/28458262/how-can-i-authenticate-my-client-side-application-through-netiq-access-manager) but I think part of my problem was that I didn't really know what I was looking for. This is my first time ever working with WCF, so it's been quite a bit of trial and error. Could you possibly point me in the right direction? – SimTrooper Jun 18 '15 at 16:21
  • Also, would it help give more context if I uploaded my .wsdl file that I'm working with? – SimTrooper Jun 18 '15 at 16:31
  • 1
    No. The problem is your firewall. You need to get it programmed to allow your SOAP traffic through. This nonsense with cookies is a hack, and a bad one. How are you authenticating in any case, and getting the cookies? – John Saunders Jun 18 '15 at 16:33
  • I should start by saying that this is for internal company use, not selling this solution to any customers. At the moment, the program is run on client machines. Using Fiddler, I captured the requests/responses that were occurring while logging into the system. When you try to go to the system address, it redirects you to the NetIQ Access Manager page, where you enter credentials. It then emails a OTP, which the user then enters. I prompt the user for credentials, then recreated the HttpWebRequest. Then I prompt the user for the OTP. I use the CookieContainer from these request/responses. – SimTrooper Jun 18 '15 at 16:41
  • Yeah, like I said. A hack. That's how NetIQ access manager is meant to work for browser requests from interactive users. I'm sure there is also a proper way to enable access by web services. Pretending you're a person isn't the right way to go. What will you do when they begin to require fingerprints or smartcards? Your code is not a person, so don't pretend it is. – John Saunders Jun 18 '15 at 16:44
  • I understand it's a hack. This program I am working on is not really within my job description, but a program that I took on the side. The NetIQ AM implementation is new to our company, and the IT person "in charge" of it doesn't know much about it. Our lack of knowledge about this combined is an issue, because I don't really know what settings I need her to change/implement to do this correctly. The "hack" is just a means of pulling these metrics for now, but I'm hoping that through interactions like these, I can learn and understand the correct way to implement this. – SimTrooper Jun 18 '15 at 16:49
  • The wrong one of you is working on the problem. The IT guy needs to find out how to enable access to your service. Pretending your client is a person is a bad idea. Happy hacking. – John Saunders Jun 18 '15 at 16:52

0 Answers0