I have come across the situation where I have the Web Service wrote during the
VB 6.0 using the Soap Toolkit from the COM component, I want to consume the Web
Service from the .Net Application (C# or ASP.net). There are few ways to consume
the Web Service either wrote from .Net version or any other application.
Here I would like to share how to consume the Web Service in .Net application.
As most of us know what is Web Service so I will not go deep into that.
I have generated the WSDL (Web Service Descriptor Language) from the COM (+)
component using the SOAP Toolkit. SOAP will generate the .WSDL, .WSMX and .asp
file which we can use to access the Web Service.
Step 1:
- Create the C# application (windows)
- Add the Web Reference and Include the WSDL file under the Web Reference folder.
- Give the name to that Web Reference i.e. CallWS
- Set the Web Reference URL to something like
http://servername/virtualdirectory/services/APIEnterprise.WSDL
Now you have the Web reference added to your application. You can now access the
Web Service and exposed API's of that Web Service.
Open the form and add the button. On Button click event will access the Web
Service and Its Function.
To access the Web Service we have to create the Instance from the Web Reference
name.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace ConsumeWebService
{
public partial
class Form1 :
Form
{
public Form1()
{
InitializeComponent();
}
private void
btnShow_Click(object sender,
EventArgs e)
{
CallWS.EyrAPIEnterprise call =
new CallWS.EyrAPIEnterprise();
call.Url = "http://server/virtualdirectory/services/APIEnterprise.asp";
//If you are using the Default Credential
then set this property to true.
//call.UseDefaultCredentials =
true;
//If you are using Windows (NTLM)
authetication then set the below property.
call.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
string systemID =
string.Empty;
XmlDocument doc =
new XmlDocument();
string xmlString = ((System.Xml.XmlNode[])call.GetSystems())[0].OuterXml;
doc.LoadXml(xmlString);
textBox1.Text = xmlString;
//You can get the value from the XML output using the XPath


Arjun DhilodPosted Sep 23, 2013, 6:13 AM
in window base application u cant see "Web Reference" this option pls correct come one
Arjun DhilodPosted Sep 20, 2013, 6:45 AM
i want to use SAP WSDL in my web project how can i use which name space add
Arjun DhilodPosted Sep 20, 2013, 6:41 AM
good post keep it up