04-23-2010 3:33 PM
HI,
How do i call a SAP webservice from .Net application.
Thanks in advance,
Anoop
04-23-2010 5:34 PM
Hi,
assuming that the SAP-side is covered, you should be able to obtain a WSDL-File from your SAP-Application Server. The address of the WSDL-File is somehow like http://yoursapserver:yourport/sap/bc/srt/rfc/sap/yourwebservicename?wsdl, where yoursapserver, yourport and yourwebservicename depend on your system settings and of course on your webservice definition.
Now start Visual Studio and create a new Windows Project. Add a web reference to your Project with the built-in wizard (right-klick in the Project-Explorer, select "Add Web-Reference"). Follow the steps in the wizard, by pasting the address of the WSDL file mentioned above and providing login data. At least, you should give it a name, which will be the name of the Proxy-Class generated by the wizard.
If the wizard finishes successfully, you can use the new class in your .NET-Project. Sample Code (VB.NET):
Dim cr As New System.Net.NetworkCredential("SAP-Username", "SAP-Password")
Dim ws As New MyWebProxyClass.ZWHOAMIService
Dim Result as String
ws.Credentials = cr
Try
Result = ws.ZWhoami()
Me.TextBox1.Text = Result
Catch ex As Exception
Me.TextBox1.Text = "Error: " & ex.Message
End Try
Hope it helps.
Rudi
04-23-2010 5:34 PM
Hi,
assuming that the SAP-side is covered, you should be able to obtain a WSDL-File from your SAP-Application Server. The address of the WSDL-File is somehow like http://yoursapserver:yourport/sap/bc/srt/rfc/sap/yourwebservicename?wsdl, where yoursapserver, yourport and yourwebservicename depend on your system settings and of course on your webservice definition.
Now start Visual Studio and create a new Windows Project. Add a web reference to your Project with the built-in wizard (right-klick in the Project-Explorer, select "Add Web-Reference"). Follow the steps in the wizard, by pasting the address of the WSDL file mentioned above and providing login data. At least, you should give it a name, which will be the name of the Proxy-Class generated by the wizard.
If the wizard finishes successfully, you can use the new class in your .NET-Project. Sample Code (VB.NET):
Dim cr As New System.Net.NetworkCredential("SAP-Username", "SAP-Password")
Dim ws As New MyWebProxyClass.ZWHOAMIService
Dim Result as String
ws.Credentials = cr
Try
Result = ws.ZWhoami()
Me.TextBox1.Text = Result
Catch ex As Exception
Me.TextBox1.Text = "Error: " & ex.Message
End Try
Hope it helps.
Rudi
05-06-2010 7:33 AM
Now able to call webservice from .Net.Thanks a lot for your valuable information
Thanks,
Anoop