none
Doing a SOAP request with C# RRS feed

  • Question

  • Hi there,

    Newbie question Im afraid... well C# newbie at least :D

    Lately I've been working on making an interface between our School Information System (SIS)  and School Data Sync (SDS). Our SIS enables us to make webservice request to queries. To my understanding this is a SOAP interface.

    Until now I've been fiddling with with Perl making URL requests and parsing the resulting csv output. A URL I use would look like this:

    https://[url]/?library=Data&function=GetData&SessionToken=[SessionToken]&Layout=[Layout]&Parameters=[Parameters] &Type=[HTML/XML/CSV/TAB]

    This works kinda good... but there is a challenge: I need to complete/check some data using AD or AAD. And I think this is better done using Powershell or C#. The SIS documentation gives an example on how to get the data via C#, so I went ahead with that. The example is:

    public Boolean Data.GetData(String SessionToken, String Layout, String Parameters, out TTable Table);

    I recognize a lot in this, most of the parameters are allso used in the URL syntax. But I feel there is something missing. Where is the connection being made for instance? Feels like the example is not complete. Obvious to a seasoned c# guru perhaps, but not to me.

    I would like verry much for this to work. Having a tTable (gather they are about the same as in Delphi?) to work with seems a lot nicer than having to parse a CSV. Could anyone help me on getting my data? RTFM pointers will be appreciated.... an example even better.

    regards

    Peter



    Sunday, December 16, 2018 9:46 AM

All replies

  • You can do it with HTTPclient.

    https://www.c-sharpcorner.com/article/calling-web-service-using-soap-request/

    Sunday, December 16, 2018 12:10 PM
  • This might be useful to you also. I have 4 blog posts about Web Services ... the first for SOAP (without the hassle of adding a ServiceReference), the other 3 for REST. This search will get you all 4:

    https://geek-goddess-bonnie.blogspot.com/search?q=proxy


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, December 16, 2018 11:59 PM
    Moderator
  • Hi Peter Kaagman,

    Thank you for posting here.

    According to your description, I have some question to confirm with you.

    >>Where is the connection being made for instance?

    1. What is the type of your project to connect with? WCF?

    >>Feels like the example is not complete.

    What do you mean it is not complete? Missing the parameter in your url? Or do you not get the value of the parameters in url?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 17, 2018 2:24 AM
    Moderator
  • >> >>Where is the connection being made for instance?

    >> 1. What is the type of your project to connect with? WCF?

    It would have to run as a service. So WCF sounds right to me.


    >> >>Feels like the example is not complete.

    >> What do you mean it is not complete? Missing the parameter in your url? Or do you not get the value of the parameters in url?

    Let me show you the complete documentation for a login request:


    Parameters: In UserName (String) Gebruikersnaam In Password (String) Wachtwoord Out ResultMessage (String) Foutmelding, indien van toepassing Out SessionToken (String) SessionToken voor gebruik bij latere aanroepen Out Result (Boolean)

    C# Syntax: public Boolean Algemeen.Login(String UserName, String Password, out String ResultMessage, out String SessionToken);

    Delphi Syntax: function Algemeen.Login(const UserName: String; const Password: String; out ResultMessage: String; out SessionToken: String): Boolean;

    URL Syntax: https://[url]/?library=Algemeen&function=Login&UserName=[UserName]&Password=[Password] &Type=[HTML/XML/CSV/TAB]


    (Sorry for the dutch... its a verbatim copy)

    I do understand the URL syntax, can use that.

    In Perl Im doing this:

    sub getToken {      
      my $ua = LWP::UserAgent->new();
      my $url = $MagisterSite."/?library=Algemeen&function=Login&UserName=$User&Password=$Pass";
      my $req = HTTP::Request->new(GET => $url);
      my $res = $ua->request($req);
    
      if ($res->is_success){
          if ($res->content =~ /.+SessionToken">(.+)<\/td>.+/) {
          return $1;
        }else{
          return "wtf";
        }
      }else{
        return $res->status_line, "\n";
      }
    }                     
    
    I guess I could use a useragent like machanism in C# too... but the documentation suggests (I think) that there is a smarter way. Making a function call and getting back a tTable object (for the GetData that is).

    But this:

    C# Syntax:
    public Boolean Algemeen.Login(String UserName, String Password, out String ResultMessage, out String SessionToken);

    does not make sense to me. It looks like a function header. What can I do with it?

    Monday, December 17, 2018 8:37 AM
  • C# Syntax:
    public Boolean Algemeen.Login(String UserName, String Password, out St...….

    It's a c# function/method that's not complete that is taking in parameters. What the behavior of the method is doing, who knows since you don't have any code for the method. 

    Monday, December 17, 2018 3:48 PM
  • hmm, the URL looks NOT like SOAP nor like REST.. More like a kind of handcrafted HTTP based-service. What does it say about that API?

    For your snippet from that reference: This is just a method header, not a sample how to use such an API. Thus can you post anything about that API?

    Monday, December 17, 2018 4:04 PM