How to connect to SAP Business Objects XI 4.0 using Web Services with ASP.NET and C#

How to connect to SAP Business Objects XI 4.0 using Web Services with ASP.NET and C#

Hello all, this is my first article and I hope it can be useful.

Introduction

I'm in charge of create a Framework capable of retrieve information from SAP BO XI database in order to create an custom application that display information according to user connected.
The first problem that I face was that knowledge base of SAP contains examples on how to do it using DLLs files that are available. The problem with this is that if you use wrong version (x86 or x64) you will spend a lot of time "playing" with compile options and, even, if you use a different server for SAP BO an Web Site, you need to install the same version on Web Server.

To avoid this problem, you can use Web Services that are installed when SAP BO is installed (These are served by Tomcat). By default, web services available can be found using http://server:8080/dswsbobje/services/listServices where server is the URL of SAP BO server.


Let's go

For this article will only use Session Web service since it contains all necessary classes to interact with SAP BO. (Current Example was created using Visual Studio 2010)
  • First we going to create a Web Application called My NET SAP Connector.

  • Go to Solution Explorer, right click and choose Add Service Reference and click on Advanced.

  • On next screen click on Add Web Reference and enter the URL for Session web server, this URL have to be gathered from http://server:8080/dswsbobje/services/listServices where server is the URL of SAP BO server.


  • Note that you need to add ?wsdl at the end of URL because when you open SAP BO web server URL, this is listed with it and if you enter as is, you will get and error.

  • Enter BO_Session on web reference name field.


  • After you finish above steps, you will have access to SAP BO Session functions and method.

Next step is to test authentication. For this, Add a Web Form to project called BO_Login and insert one Label with text User, other with text Password, one Textbox with ID txtUser, other with ID txtPass, a button with text Login and ID btnBO_Login and a label with id lblResult.


Double click on button to add method btnBO_Login_Click and insert next code:
protected void btnBO_Login_Click(object sender, EventArgs e)
        {
            try
            {
                // Create Credentials Objects to hold credentials provided by user at login page
                BO_Session.EnterpriseCredential objCredential = new BO_Session.EnterpriseCredential();
                objCredential.Login = txtUser.Text;
                objCredential.Password = txtPass.Text;
                objCredential.Domain = "server:6400";
                objCredential.AuthType = "secEnterprise";
 
                // Create Session for BI Server and Login
                BO_Session.Session objSession = new BO_Session.Session();
                BO_Session.SessionInfo objSessionInfo = objSession.login(objCredential, objSession.getVersion());
 
                lblResult.Text = "User " + txtUser.Text + " authenticated ";
            }
            catch (Exception ex)
            {
                lblResult.Text = "Error on Authentication. " + ex.Message;
            }
        }

Run with F5, enter valid user and password and click Login button.


Conclusion

Use web services is the easiest way to connect to SAP BO database because it does not depend on platform used, we don't need additional libraries or files and (not included on this article) these web services allow us extract information from SAP BO database like user information, groups where users belongs, reports available, etc.
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Jim Vazquez Castan edited Original. Comment: Add some comments

Page 1 of 1 (1 items)