Yes I am begging for and example of a SOAP client in C#
-
Shamefully I come to you all. I have searched high and low with varying success on how to create, post, and receive a SOAP message to a simple Web Service. I am terribly confused on how to go about it with the different types of ways to do it. I don't consider myself to be a noob but I feel like a babe in the woods right now. Therefore I am at the point where I am not too proud to beg. If there is anyone that knows of a good tutorial (that is clearer than what Microsoft offers, a slightly working example or any complete documentation on how to create, post and receieve a SOAP package to a Web Service I would be more than appreciative. Thank you to all that even consider my request. Also I apologize for being such a bug with my request. I assure you though that I spent more than a week investigating and trying things out. I do not take anyone's time for granted. Happy Holidays....' F
-
Shamefully I come to you all. I have searched high and low with varying success on how to create, post, and receive a SOAP message to a simple Web Service. I am terribly confused on how to go about it with the different types of ways to do it. I don't consider myself to be a noob but I feel like a babe in the woods right now. Therefore I am at the point where I am not too proud to beg. If there is anyone that knows of a good tutorial (that is clearer than what Microsoft offers, a slightly working example or any complete documentation on how to create, post and receieve a SOAP package to a Web Service I would be more than appreciative. Thank you to all that even consider my request. Also I apologize for being such a bug with my request. I assure you though that I spent more than a week investigating and trying things out. I do not take anyone's time for granted. Happy Holidays....' F
Ok. Here is the steps to create a simple web service. 1 - Create an empty solution in the Visual Studio. I assume you are using VS2008. 2 - Right click on the solution icon in the solution explorer and choose add new project. 3 - Choose the "ASP.NET web service application" template and click "OK". Give it any name you like. I named it "Webservice1". 4 - Open the service1.asmx.cs file and add the following code.
[WebMethod]
public string GetGreetings(string yourName)
{
return "Have a good day, " + yourName;
}The
WebMethod
attribute indicates that this method can be called by a web service client. 5 - Right click on service1.asmx and choose "View in browser". You have created a service now. We need to create a client to use this service. 1 - Right click on the solution icon in the solution explorer and choose Add - New project. Select Console application template. 2 - Right click on References and choose Add service reference. 3 - Give the URL and click ok. VS will generate the proxy classes depending on the WSDL. 4 - Write the following code to use the service.class Program
{
static void Main(string[] args)
{
var client = new Service1SoapClient();
string greetings = client.GetGreetings("Chuck Norris");
Console.WriteLine(greetings);
}
}:)
Best wishes, Navaneeth
-
Ok. Here is the steps to create a simple web service. 1 - Create an empty solution in the Visual Studio. I assume you are using VS2008. 2 - Right click on the solution icon in the solution explorer and choose add new project. 3 - Choose the "ASP.NET web service application" template and click "OK". Give it any name you like. I named it "Webservice1". 4 - Open the service1.asmx.cs file and add the following code.
[WebMethod]
public string GetGreetings(string yourName)
{
return "Have a good day, " + yourName;
}The
WebMethod
attribute indicates that this method can be called by a web service client. 5 - Right click on service1.asmx and choose "View in browser". You have created a service now. We need to create a client to use this service. 1 - Right click on the solution icon in the solution explorer and choose Add - New project. Select Console application template. 2 - Right click on References and choose Add service reference. 3 - Give the URL and click ok. VS will generate the proxy classes depending on the WSDL. 4 - Write the following code to use the service.class Program
{
static void Main(string[] args)
{
var client = new Service1SoapClient();
string greetings = client.GetGreetings("Chuck Norris");
Console.WriteLine(greetings);
}
}:)
Best wishes, Navaneeth
Navaneeth, You are about to become my hero!!! Thank you very much for the time you took to detail this out for me. Works just like you would expect it to. Again my deepest thanks. Now, my problem is that when I try to run it again a another WebService, I get an error stating that the message SOAP message is malformed. I see that the SOAP-ENV is missing (I have invested in a sniffer program to assist) so that is where the problem lies. Is there anywhere that I could make sure that the SOAP message contains this or any other tag? Is there a way to manually build the message?
-
Navaneeth, You are about to become my hero!!! Thank you very much for the time you took to detail this out for me. Works just like you would expect it to. Again my deepest thanks. Now, my problem is that when I try to run it again a another WebService, I get an error stating that the message SOAP message is malformed. I see that the SOAP-ENV is missing (I have invested in a sniffer program to assist) so that is where the problem lies. Is there anywhere that I could make sure that the SOAP message contains this or any other tag? Is there a way to manually build the message?
Usually you don't care about the raw SOAP message because VS generates proxy classes for it and you work directly with these classes. When you change the web service, you need to update the web reference which will regenerate the proxy classes with the latest SOAP message format.
Best wishes, Navaneeth