Example: Complex Sequences for Soap Service Calls

Adding web references can be done in Visual Studio. This generates a proxy class that consumes the TecRMI SOAP service and the related object model automatically. Required assembly references will also be automatically added.

  • Go to the project explorer and rightclick on references of the project where you want to add the web reference.
  • In the context menu click "Add Service Reference...".
  • In the opened dialog click "Advanced...".
  • In the opened dialog click "Add Web Reference...".
  • Type the service address "https://rmi-services.tecalliance.net/soap/ServiceLt.asmx" in the "URL" field.
  • Click the "Go" button and wait until the service is found.
  • Type "Services.TecRMI.Lt" as namespace of the service proxy class in the "Web Reference Name" field.
  • Click "Add Reference".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Web.Services.Protocols;
using Examples.CSharp.Soap.Services.TecRMI.Lt;
 
namespace Examples.CSharp.Soap
{
    /// <summary>   A SOAP example. </summary>
    public static partial class SoapExample
    {
        /// <summary>   Example of complex call. </summary>
        /// <remarks>
        /// This example shows how to call the service which returns a complex data structure.
        /// </remarks>
        /// <param name="company">  The company. </param>
        /// <param name="account">  The user name. </param>
        /// <param name="password"> The password. </param>
        public static void CallWithComplexReturnType(string company, string account, string password)
        {
            // Create method specific message object.
            var msg = new GetLtWorkStepsMsg
            {
                // Set credentials
                CompanyName = company,
                UserName = account,
                Password = password,
 
                // Set method specific parameters
                LanguageCode = "en",
                CountryCode = "GB",
                TypeId = 13494,
                ItemMpId = 244,
                KorId = 7,
                BodyQualColId = 0,
                KindOfWorkTime = KindOfWorkTimeData.DecimalWorkHours,
                ConsumerId = "ExampleConsumer",
            };
 
            // response type
            LtWorkPos[] ltWorkPoses;
 
            using (var serviceLt = new ServiceLt { Url = "https://rmi-services.tecalliance.net/soap/ServiceLt.asmx" })
            {
                try
                {
                    // Call service method using the proxy.
                    ltWorkPoses = serviceLt.GetLtWorkSteps(msg);
                }
                catch (SoapException ex)
                {
                    // SOAP exception occurs if errors on TecRMI side occur, see message (e.g. "Permission denied")
                    Console.WriteLine("SOAP Error: {0}", ex.Message);
                    serviceLt.Abort();
                    return;
                }
                catch (Exception ex)
                {
                    // other exception (e.g. timeout)
                    Console.WriteLine("other Error: {0}", ex.Message);
                    serviceLt.Abort();
                    return;
                }
            }
 
            // Process the response
            foreach (var workPos in ltWorkPoses)
            {
                Console.WriteLine("- [{0}] {1} {2} ({3})", workPos.WorkPosNo ?? string.Empty, workPos.ItemMpText, workPos.KorText, workPos.QualColText);
                Console.WriteLine("\t- Exclusives:");
                foreach (var excl in workPos.ExclusiveWorkPositions)
                {
                    Console.WriteLine("\t\t- [{0:0.00} h] {1} {2} ({3})", excl.WorkTime, excl.ItemMpText, excl.KorText, excl.QualColText);
                }
                Console.WriteLine("\t- Optional Exclusives:");
                foreach (var opeExcl in workPos.OptionalExclusivePositions)
                {
                    Console.WriteLine("\t\t- [{0:0.00} h] {1} {2} ({3})", opeExcl.WorkTime, opeExcl.ItemMpText, opeExcl.KorText, opeExcl.QualColText);
                }
            }
        }
    }
}
 
©   TecAlliance GmbH