“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.