question

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

Possibilities to include a SOAP interface in C# WinForm.

Hello,

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.


 //Request
     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pdc="http://xmlns.oracle.com/orav/P/PDME">
        <soapenv:Header/>
        <soapenv:Body>
           <pdc:SELECT_ORDERInput>
              <pdc:P_IN-REQUEST_CONTAINER-CIN>
                 <pdc:REQUEST_CONTAINER>
                    <pdc:MESSAGEID>F7DE84C6-9999-8888-831F-9ED3D8CF9E1B</pdc:MESSAGEID>
                    <pdc:TIMESTAMP>2021-10-07T09:25:00.063+02:00</pdc:TIMESTAMP>
                    <pdc:INTERFACEID>IF0001</pdc:INTERFACEID>
                    <pdc:REQ_DATA>
                       <pdc:SITE>B551</pdc:SITE>
                       <pdc:AREA>225S</pdc:AREA>
                       <pdc:EQUIP_NAME>LMWQWQW01</pdc:EQUIP_NAME>
                       <pdc:SHOP_ORDER>1522451680</pdc:SHOP_ORDER>
                    </pdc:REQ_DATA>
                 </pdc:REQUEST_CONTAINER>
              </pdc:P_IN-REQUEST_CONTAINER-CIN>
              <pdc:P_OUT-LME_SEL_RESP-COUT/>
           </pdc:SELECT_ORDERInput>
        </soapenv:Body>
     </soapenv:Envelope>
    
 //Response
 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
       <SELECT_ORDEROutput xmlns="http://xmlns.oracle.com/orav/P/PDME">
          <P_OUT>
             <LME_SEL_RESP>
                <MESSAGEID>F7DE84C6-9999-8888-831F-9ED3D8CF9E1B</MESSAGEID>
                <TIMESTAMP>2021-10-07T11:28:21.618+02:00</TIMESTAMP>
                <INTERFACEID>IFSSS0001</INTERFACEID>
                <PROCESSINGSTATUS>
                   <RETURNVALUE>1</RETURNVALUE>
                   <RETURNCODE>0</RETURNCODE>
                   <RETURNDESCRIPTION/>
                </PROCESSINGSTATUS>
                <RESPONSE_DATA>
                   <EQUIP_NAME>LMWQWQW01</EQUIP_NAME>
                   <SHOP_ORDER>1522451680</SHOP_ORDER>
                   <WORKCENTER>12EEEQ5S</WORKCENTER>
                   <RELEASE_STAMP>2021-09-03T12:18:21.618+02:00</RELEASE_STAMP>
                   <ORDER_PRIORITY>5030</ORDER_PRIORITY>
                   <QUANTITY>2</QUANTITY>
                   <ISSUE>5</ISSUE>
                   <REVISION>7,</REVISION>
                   <PANEL_LIST>
                      <LME_SEL_PANEL>
                         <PANEL_ID>130eeB744112346G123</PANEL_ID>
                         <PRODUCTGROUP_ID>15451680_130B7441123456G123</PRODUCTGROUP_ID>
                         <BLOCK_LIST>
                            <LME_SEL_BLOCK>
                               <BLOCK_ID>PA</BLOCK_ID>
                               <BARCODE>130645671123</BARCODE>
                               <INFO_TEXT>130B74423</INFO_TEXT>
                            </LME_SEL_BLOCK>
                            <LME_SEL_BLOCK>
                               <BLOCK_ID>AA</BLOCK_ID>
                               <BARCODE>13066744112323</BARCODE>
                               <INFO_TEXT>130B74411235123</INFO_TEXT>
                            </LME_SEL_BLOCK>
                         </BLOCK_LIST>
                      </LME_SEL_PANEL>
                      <LME_SEL_PANEL>
                         <PANEL_ID>130ffB744156G123</PANEL_ID>
                         <PRODUCTGROUP_ID>15451680_130B74411123</PRODUCTGROUP_ID>
                         <BLOCK_LIST>
                            <LME_SEL_BLOCK>
                               <BLOCK_ID>PA</BLOCK_ID>
                               <BARCODE>16744112375671123</BARCODE>
                               <INFO_TEXT>130B7423756G123</INFO_TEXT>
                            </LME_SEL_BLOCK>
                         </BLOCK_LIST>
                      </LME_SEL_PANEL>
                   </PANEL_LIST>
                </RESPONSE_DATA>
             </LME_SEL_RESP>
          </P_OUT>
       </SELECT_ORDEROutput>
    </soap:Body>
 </soap:Envelope>


dotnet-csharpdotnet-adonet
· 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?

www.soapui.org

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 : https://gls.lotro.com/GLS.DataCenterServer/Service.asmx?WSDL
where I send the command GetDatacenters (in "SOAPAction") to get a list of LOTRO servers :

 HttpWebRequest httpWebRequest = ((HttpWebRequest)(WebRequest.Create("https://gls.lotro.com/GLS.DataCenterServer/Service.asmx")));
 httpWebRequest.Method = "POST";
 string sPostData = @"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
     <soap:Body>
         <GetDatacenters xmlns=""http://www.turbine.com/SE/GLS"">
             <game>LOTRO</game>
         </GetDatacenters>
     </soap:Body>
 </soap:Envelope>";
 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);
 dataStream.Close();
    
 httpWebRequest.Headers.Add(HttpRequestHeader.AcceptEncoding, "txt");
 // httpWebRequest.Headers.Add(HttpRequestHeader.UserAgent, "Test");
 httpWebRequest.Headers.Add("SOAPAction", "http://www.turbine.com/SE/GLS/GetDatacenters");
    
 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();
     Console.WriteLine(responseFromServer);
 }
 webResp.Close();




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

Hello,

Thanks!

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

How can I read the variables afterwards?

 <Name>Shadowfax</Name>
 <LoginServerUrl>(invalid service specified)</LoginServerUrl>
 <ChatServerUrl>198.252.160.128:2900</ChatServerUrl>
 <StatusServerUrl>http://198.252.160.28/GLS.STG.DataCenterServer/StatusServer.aspx?s=10.192.145.130</StatusServerUrl>
 <Order>2</Order>
 <Language>EN</Language>

What is the best way to do this?

140419-how-you-read.png

Thanks for more tips.


Service.asmx

Service.asmx



0 Votes 0 ·
how-you-read.png (142.1 KiB)
Castorix31 avatar image Castorix31 MarkusFreitag-0088 ·

But you should have a WSDL address
In my test, I can use Generic SOAP Client
to test the request and response with https://gls.lotro.com/GLS.DataCenterServer/Service.asmx?WSDL

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=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
      <soap:Body>
          <GetDatacenters xmlns=""http://www.turbine.com/SE/GLS"">
              <game>LOTRO</game>
          </GetDatacenters>
      </soap:Body>
  </soap:Envelope>";

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