MarkusFreitag-0088 avatar image
0 Votes"
MarkusFreitag-0088 asked MarkusFreitag-0088 commented

Possibilities to include a SOAP interface in C# WinForm.


What is the best way to create a SOAP request in C#?
Can i simulate the answers? If so, what is the best way?
Can I ask the customer if they have a WSDL file. Would it be easier then? Such a file, can it be created easily? I don't know, never done it before.

How would I have to include it in my C# WinForms, desktop project?

Do you have a sample code for me. THANKS.

     <soapenv:Envelope xmlns:soapenv="" xmlns:pdc="">
 <soap:Envelope xmlns:soap="">
       <SELECT_ORDEROutput xmlns="">

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SOAP uses the Web Service Description Language (WSDL) to define the methods and types available in the SOAP service. The service you are trying to consume should have instructions that explain how to get to the WSDL. You might have to create an account first. Again, the SOAP service should have documentation that explains what to do.

Then all you have to do is use Visual Studio to create a web reference (proxy). It takes a few seconds. What happens behind the scene is Visual Studio generates code (proxy) that allows you to access the SOAP service. You'll interact with the service as if the service is a library on your machine.

But - you need to read the docs to know what features the SOAP service exposes and what data is passed back and forth. SOAP is a very mature service and there's plenty of information on the web.

1 Vote 1 ·

Hello again,

My client is quite difficult and I don't get any support.
What I have?
A WSDL file.
With the console
wsdl /par SCADA_LE_1.wsdl
I could create the wrapper class.

I haven't a asmx file.
http://<server>/<customsite>/_vti_bin/excelservice.asmx or http://<server>/_vti_bin/excelservice.asmx.

How can I simulate SOAP so that I get a response back?

Do you know how this works?
Do you know a good youtube tutorial video?

Can you give me an example here? would be nice and best.

Thanks in advance.

0 Votes 0 ·
AgaveJoe avatar image AgaveJoe MarkusFreitag-0088 ·

How can I simulate SOAP so that I get a response back?

I recommend creating a ASMX or WCF service in Visual Studio. Then play around until you get the idea. Basically teach yourself basic SOAP in .NET. Again, this is not a new subject and there's a lot of information on the web.

Write a web service by using Visual C# .NET

Once you get the hang of SOAP then you should be able to work with your client's SOAP service. It really is quite simple. But you need to know what features the service exposes and how to use these features in your application.

0 Votes 0 ·

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered MarkusFreitag-0088 commented

You can use HttpWebRequest
A test with the game LOTRO, WSDL :
where I send the command GetDatacenters (in "SOAPAction") to get a list of LOTRO servers :

 HttpWebRequest httpWebRequest = ((HttpWebRequest)(WebRequest.Create("")));
 httpWebRequest.Method = "POST";
 string sPostData = @"<soap:Envelope xmlns:xsi="""" xmlns:xsd="""" xmlns:soap="""">
         <GetDatacenters xmlns="""">
 byte[] byteArray = Encoding.UTF8.GetBytes(sPostData);
 // httpWebRequest.ContentType = "application/x-www-form-urlencoded";
 httpWebRequest.ContentType = "text/xml; charset=utf-8";
 httpWebRequest.ContentLength = byteArray.Length;
 httpWebRequest.UserAgent = "Test";
 Stream dataStream = httpWebRequest.GetRequestStream();
 dataStream.Write(byteArray, 0, byteArray.Length);
 httpWebRequest.Headers.Add(HttpRequestHeader.AcceptEncoding, "txt");
 // httpWebRequest.Headers.Add(HttpRequestHeader.UserAgent, "Test");
 httpWebRequest.Headers.Add("SOAPAction", "");
 WebResponse webResp = httpWebRequest.GetResponse();
 Console.WriteLine("Web response : {0}",((HttpWebResponse)(webResp)).StatusDescription);
 using (Stream str = webResp.GetResponseStream())
     StreamReader streamReader = new StreamReader(str);
     string responseFromServer = streamReader.ReadToEnd();

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.



What do you recommend?
Should I not create a wrapper class WSDL.EXE?

How can I read the variables afterwards?

 <LoginServerUrl>(invalid service specified)</LoginServerUrl>

What is the best way to do this?


Thanks for more tips.



0 Votes 0 ·
how-you-read.png (142.1 KiB)

But you should have a WSDL address
In my test, I can use Generic SOAP Client
to test the request and response with

The response is in XML format, so easy to parse (or there are threads like c# parse soap response for attribute values and if child node exists)

0 Votes 0 ·

  string sPostData = @"<soap:Envelope xmlns:xsi="""" xmlns:xsd="""" xmlns:soap="""">
          <GetDatacenters xmlns="""">

I still have great problems
with or without WSDL

How can I simulate the answer. How do I create the server?
Is there a step by step guide?

0 Votes 0 ·
Show more comments