Sunday, 28 April 2013

Consuming a Web Service in Saba using .NET

Consuming a Web Service in Saba happens in two steps:

1) Authorization of the consumer via a service exposed by Saba and available at the following address:
This service returns a certificate to use in step 2

2) Invoke the web service exposed by your installation of Saba using the certificate

To make life easier with step 1, Saba distributes a .NET assembly that is a wrapper around that service; this wrapper contains two classes in the Saba.Platform namespace:

  • SabaLogin, that you should use for authentication

  • InfoServiceClient, that you should use for invoking your own service
  •  

A quick example of how to use the above classes in C#:

string username = "admin";
string password = "welcome";

// get an authentication certificate
string certificate = SabaLogin.Authenticate(endpointURL, username, password);

// invoke the "updateUsername" service
Hashtable requestParams = new Hashtable();
requestParams["old_username"] = "JSMITH";
requestParams["new_username"] = "HPOTTER";

XmlDocument response = InfoServiceClient.CallService(
   endpointURL,
   "updateUsername",
   certificate,
   requestParams);

requestParams is a map of parameters to pass to the service (no generics yet, Saba is still on the old-fashioned .NET 1.1 code...)
 
Communication is over SOAP, no REST services in Saba yet.
 
Enjoy!
Vriendelike groete
@stefanotempesta
 

15 comments:

  1. Hello. I am actually working on the Saba API and have a question. I see that that the RESTful web service now exists. I can retrieve a certificate but keep getting "(500) Internal Server Error" whenever I try to use any other method. For example: /Saba/api/common/infoservice/profile. I pass the certificate as a string parameter and also pass username as a search parameter.

    Do I pass the entire certificate string (i.e. {'SabaCertificateWrapper': {'@type:SabaCertificate', 'certificate':'31343.......') or just the long number part?

    Thanks Niall

    ReplyDelete
    Replies
    1. Niall, did you ever resolve your issue? I am experiencing the same thing.

      Delete


    2. - Ngươi vào bằng cách nào, ngươi đã tiến vào học viện ma pháp sao?

      Yến Hiểu Kỳ khẽ đóng cửa sổ lại, thẹn thùng nói với Nhạc Thành. Cho tới bây giờ nàng vẫn không thể tin được tất cả mọi chuyện là thật sự.

      - Hiện tại ta đã vào học viện đấu khí, dự định hai ngày nữa sẽ bế quan nửa năm chđồng tâm
      game mu
      cho thuê phòng trọ
      cho thuê phòng trọ
      nhac san cuc manh
      tư vấn pháp luật qua điện thoại
      văn phòng luật
      số điện thoại tư vấn luật
      dịch vụ thành lập doanh nghiệpo nên tới đây thăm ngươi.

      Nhạc Thành cất tiếng trả lời, ánh mắt quét quanh Yến Hiểu Kỳ.

      Chỉ nhìn thấy trên người của Yến Hiểu Kỳ mặc một bộ váy hồng, trước ngực là bộ ngực sữa đày đặn, khe núi thật sâu nóng bỏng, bờ eo nhỏ mềm mại. Nhạc Thành nhìn thấy vậy thì không kìm được nuốt nước miếng.

      - Cha ta đã nói với ngươi chưa?

      Yến Hiểu Kỳ nhìn Nhạc Thành, khuôn mặt yêu kiều.

      Yến Hiểu Kỳ ở ma pháp học viện, cha nàng cũng đã nói với nàng chuyện thông gia với Nhạc gia, lúc đó trong lòng nàng vô cùng cao hứng, chỉ là không biết

      Delete
  2. Hi Niall,
    The header key should be "SabaCertificate" and the value is just the long number.

    How did you go with calling the rest of the API? I keeping getting "No message body writer has been found for response class WebApplicationException" when calling "Saba/api/common/infoservice/catalogsearch"

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Do these web services are available in Saba Cloud? Specially the Authentication ws.

    ReplyDelete
    Replies
    1. Yes, Web Services are available also in Saba Cloud.

      Delete
  5. Where can I find the .Net Assembly?

    ReplyDelete
    Replies
    1. The .Net assembly is distributed by Saba, ask Saba Support for help.

      Delete
    2. I did ask but not very responsive.

      Delete
    3. Write me in private, I'll see if I can help.

      Delete
    4. Is there something I can use for Java EE Web application to consume the Saba rest service? I would like to build a calendar and we don't have access to .NET but I can use Java EE and Netbeans.

      Delete
    5. The best way to invoke a Web Service in Java is to use JAX-WS. As you are using Netbeans, have a look at this tutorial for some examples: https://netbeans.org/kb/docs/websvc/jax-ws.html

      Delete
  6. Hi Stefano,
    Thanks for your guide, but can you send me .net assembly please. I can not find any from saba support. My email: homthu_abc@yahoo.com
    Thanks.

    ReplyDelete
  7. I know that this post is dated, but I'm having difficulty using the SABA API with .NET and I'm not getting much in the way of support. Does anyone have any a code sample that uses the REST Services to create a profile for example. My email address is aggie4ga-bbb@yahoo.com Thanks for any help.

    ReplyDelete