Friday, December 19, 2008

Let's Talk about .. Visual Studio 2003-Create SAP Web Service

P'Aoi, expert of dotNet in IT-BOT teached me how to create SAP Web Service.

The instruction to Create SAP Web Service

-Right Click at Your Project
-Click Add
-Click Add New Item
-Select Web Service
-Type Name: [Your Web Service Name].asmx
-Click OK

-In the .vb code, import the following libraries
[VB.Net]
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Configuration

-Set
[VB.Net]
{system.web.services.webservice(namespace:=http://localhost/[Your Project]/[Your Web Service Name])> _
{system.web.services.webservicebinding(conformsto:=wsiprofiles.basicprofile1_1)> _
{toolboxitem(false)> _

-Declare and define SAP Connection String
[VB.Net]
Dim cs As String = System.Configuration.ConfigurationSettings.AppSettings("[Your SAP Connection String]")

-Declare Get SAP Connection Function
[VB.Net]
Private Function GetSAPConnection() As SAP.Connector.Connection
Dim objDest As New SAP.Connector.Destination
objDest.AppServerHost = System.Configuration.ConfigurationSettings.AppSettings("AppServerHost")
objDest.SystemNumber = System.Configuration.ConfigurationSettings.AppSettings("SystemNumber")
objDest.Client = System.Configuration.ConfigurationSettings.AppSettings("Client")
objDest.Language = System.Configuration.ConfigurationSettings.AppSettings("Language")
objDest.Username = System.Configuration.ConfigurationSettings.AppSettings("Username")
objDest.Password = System.Configuration.ConfigurationSettings.AppSettings("Password")
Return SAP.Connector.Connection.GetConnection(objDest)
End Function

-Create Your Function accoring to your SAP RFC like the example Hello World

No comments: