Example: Complex Parameters 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/ServiceVt.asmx" in the "URL" field.
  • Click the "Go" button and wait until the service is found.
  • Type "Services.TecRMI.Vt" 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Web.Services.Protocols;
using Examples.CSharp.Soap.Services.TecRMI.Vt;
 
namespace Examples.CSharp.Soap
{
    /// <summary>   A SOAP example. </summary>
    public static partial class SoapExample
    {
        /// <summary>   Example of a complex call. </summary>
        /// <remarks>
        /// This example shows how to call the service by submitting a complex data structure as
        /// parameters via POST.
        /// </remarks>
        /// <param name="company">  The company name. </param>
        /// <param name="account">  The user name. </param>
        /// <param name="password"> The password. </param>
        public static void CallWithComplexParameterType(string company, string account, string password)
        {
            // Create the method specific message object
            var msg = new GetVtMakeListMsg
            {
                // Set credentials
                CompanyName = company,
                UserName = account,
                Password = password,
 
                // Set method specific parameters
                LanguageCode = "en",
                CountryCode = "GB",
                ComponentTypeIdFilter = null,
                ModuleFilter = VtModulFilter.Lt,
                RangeNameFilter = "LEON",
                ShowBike = false,
                ShowCar = true,
                ShowTruck = false,
                TypeNameFilter = "TSI",
 
                // complex parameter
                AddInfoKeyFilter = new[]
                {
                    new AddInfoKeyFilterParameter
                    {
                        // filter for build in year
                        AddInfoKeyId = 3,
                        AddInfoKeyFilterValue = "200711",
                    },
                    new AddInfoKeyFilterParameter
                    {
                        // filter for power in kW
                        AddInfoKeyId = 5,
                        AddInfoKeyFilterValue = "92",
                    },
                    new AddInfoKeyFilterParameter
                    {
                        // filter for capacity in ccm
                        AddInfoKeyId = 6,
                        AddInfoKeyFilterValue = "1390",
                    },
                    new AddInfoKeyFilterParameter
                    {
                        // filter for VIN
                        AddInfoKeyId = -8,
                        AddInfoKeyFilterValue = "VSSZZZ1PZCR073037",
                    }
                },
            };
 
            // response type
            VtMake[] makes;
 
            using (var serviceVt = new ServiceVt { Url = "https://rmi-services.tecalliance.net/soap/ServiceVt.asmx" })
            {
                try
                {
                    // Call service method using the proxy.
                    makes = serviceVt.GetVtMakeList(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);
                    serviceVt.Abort();
                    return;
                }
                catch (Exception ex)
                {
                    // other exception (e.g. timeout)
                    Console.WriteLine("other Error: {0}", ex.Message);
                    serviceVt.Abort();
                    return;
                }
            }
 
            // Process the response
            Console.WriteLine(" Id         | IsLocked | InfoDataExists | Name");
            Console.WriteLine("------------+----------+----------------+------------");
            foreach (var make in makes)
            {
                Console.WriteLine(
                    " {0,10} | {1,-8} | {2,-14} | {3}",
                    make.MakeId,
                    make.IsLocked,
                    make.InfoDataExists,
                    make.MakeName);
            }
        }
    }
}
 
©   TecAlliance GmbH