Skip to Content

This example shows you how to create an SAP Web Service from an SAP function module for use by a service account. The Web Service is then called from a .Net Application.

In reality, you might not want Web Services to be used by service accounts since anyone who knows the WSDL would be able to execute the Web Service.  I’ll show you how to actually pass the user credentials to the web service in my next example.

  

Step 1

   

Either create or choose an SAP function module you want to enable as a web service.  Make sure it is RFC enabled.  This is what I will use for this example:

/wp-content/uploads/2013/03/pic__193025.jpg

Step 2

Now we need to create a web service from the RFC definition.  SAP has provided a very nice option of creating the proxy stub for you.  From the utilities menu, choose the following:

/wp-content/uploads/2013/03/pic__193025.jpg

The Create Web Service Wizard will walk you through the steps.  Here is mine:

/wp-content/uploads/2013/03/p_193027.jpg

/wp-content/uploads/2013/03/p_193027.jpg

/wp-content/uploads/2013/03/p_193027.jpg

/wp-content/uploads/2013/03/p_193027.jpg

/wp-content/uploads/2013/03/p_193027.jpg

Once you finish this wizard, save and activate your web service.

Step 3

Go to transaction: SOAMANAGER

Choose the “Web Service Configuration” option from the Service Administration tab.

/wp-content/uploads/2013/03/p_193027.jpg

You can now search for your service definition and select “Apply Selection” as follows:

/wp-content/uploads/2013/03/p_193027.jpg

Choose the “Configurations” tab and select “Create”.  Enter details similar to the following and select “Apply Settings”:

/wp-content/uploads/2013/03/p_193027.jpg

Enter the following information on the “Provider Security” tab:

/wp-content/uploads/2013/03/p_193027.jpg

Save these changes.

Select (in the overview section):

/wp-content/uploads/2013/03/p_193027.jpg

Copy the WSDL URL link that is provided.  You will need this for your .Net application

Step 4

Now you are ready to call this web service from a .Net (or other) application.

Open up your Visual Studio project and add a web reference to the WSDL URL you copied above.

Here is my web reference:

/wp-content/uploads/2013/03/p_193027.jpg

Now to test this Web Service, create a web form and enter code similar to the following:

/wp-content/uploads/2013/03/p_193027.jpg

When I execute this program, I see the following returned data:

/wp-content/uploads/2013/03/p_193027.jpg

As you can see, we successfully executed the SAP web service from the .Net application.  This example is using the same service account for every call.  A more realistic example would be to use the credentials of the user of the web page. See my other example for that.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Felix Baumann

    Hi, nice explaination. I created a webservive in SAP and now i am trying to consume the serive from an outllok Addin. Not a web Page. Do you have any knowledge in this?

    BR

    Felix

    (0) 

Leave a Reply