iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 11, 2008
Improving accessibility for motor impaired users
WebDevTips UK
 
May 11, 2008
10 ways to orientate users on your site
WebDevTips UK
 
May 11, 2008
Web Design Clinic - Rros restoration camp 2006
About
 
May 10, 2008
The Moods of Facebook
About
 
May 9, 2008
CSS 1 properties are a great start
About
 
May 9, 2008
Reader Question: How do you get fancy fonts?
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /ASP.NET

WebService proxy file from a WSDL File 

  Views:    6954
  Votes:    9
by Balaji Ramachandran 7/23/04 Rating: 

Synopsis:

This article explains about to build a webservice proxy file from a WSDL file using the WSDL.exe.
Pages: 
The Article


“I was given a DISCO and WSDL file and a URL in order to call a web service
(not written in dot net)
I am not sure what to do this information.
I could code the request by building a soap xml message and using http post
but is there some other way to do this without writing all this code?
In this case there is no http location to add the web reference”

This was the interesting post I saw in the web services newsgroup.

Here comes the WSDL.exe to help us out.

This
tool generates code for XML Web service clients from WSDL files.


To test this, let us create a sample web service.
Create a new web service project. I gave the project name as WSTest1.

Take the default web service code generated by the visual studio as it is.
Uncomment the web method HelloWorld.
Add a new web method HelloWorld2
[WebMethod]
public string HelloWorld()
{
    return "Hello World";
}

[WebMethod]
public string HelloWorld2()
{ 
    return "Hello World2";
}

Save and compile the project.

Well. We have created the web service.
Now let us create a web service client.

Open the visual studio and create a windows application project.
I gave the project name as WSClient1.

Add a web reference to the web service we have just created.

Add a new button control in the windows form and in the click event add the following code.

private void button1_Click(object sender, System.EventArgs e)
{
    localhost.Service1 src = new localhost.Service1();
    string retValue = src.HelloWorld2();
    MessageBox.Show(retValue);
}


Save and run the code.

Click the button1. Now you’ll get the HelloWorld2 in the messagebox..

Well. Our web service works very well.

Hey. Hold on for a sec.
We are not calling the web service method using the WSDL file.
We just use the web reference and call the web service.

I hear you buddy. Let’s do that now.

Copy the Service1.disco (it can be found under yourProject\ Web References\localhost)
Paste it under yourProject folder.

Well. Go to the visual studio .net command prompt.
Change the command prompt folder to your specific project folder.

Enter the output file path and the wsdl file path
e.g.) wsdl /out:myproxy.cs Service1.wsdl

The specified proxy file will be created to your current command prompt
folder.

Now open your web service client project.
Add this generated proxy file (myproxy.cs) to your project(WSClient1.csproj).

Create one more button in the windows form.
Add the following code.

private void button2_Click(object sender, System.EventArgs e)
{
    Service1 src2 = new Service1();
    string retvalue = src2.HelloWorld();
    MessageBox.Show(retvalue);
}


Save and run the code.

Click the button1. Now you’ll get the HelloWorld in the messagebox..

Now you know you can call a web service without any web reference but with a WSDL file.

Pages: 

Similar/related articles:


 
  Sponsors