Last modified by Nico Lemaire on 2025/05/06 15:49

From version 1.3
edited by Roelof Zwaan
on 2021/11/23 11:40
Change comment: Update document after refactoring.
To version 1.4
edited by Robin Huisman
on 2022/02/08 11:45
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.RoelofZwaan
1 +XWiki.RobinHuisman
Content
... ... @@ -91,96 +91,56 @@
91 91  |9|Go back to step 5, for every Customer code, every language.| | | | |
92 92  |10|Process the LabDeliveryFiles| | | | |
93 93  
94 -
95 95  == Get Customers (POST) ==
96 96  
97 97  === Request example ===
98 98  
99 99  |(((
99 +{{code language="C#"}}
100 100  public GetCustomersCall.Response GetCustomers(string WebserviceUsername, string WebservicePassword, string CustomerUsername)
101 +        {
102 +            GetCustomersCall.Response set = new GetCustomersCall.Response();
101 101  
102 - {
104 +            try
105 +            {
106 +                var content = new FormUrlEncodedContent(new[]
107 +                {
108 +                    new KeyValuePair<string, string>("userName", WebserviceUsername),
109 +                    new KeyValuePair<string, string>("password", WebservicePassword),
110 +                    new KeyValuePair<string, string>("customerUsername", CustomerUsername),
111 +                });
103 103  
104 - GetCustomersCall.Response set = new GetCustomersCall.Response();
113 +                HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetCustomers", content).Result;
114 +                response.EnsureSuccessStatusCode();
115 +                string responseMessage = response.Content.ReadAsStringAsync().Result;
105 105  
117 +                if (string.IsNullOrEmpty(responseMessage))
118 +                {
119 +                    throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " / GetCustomers" + "]");
120 +                }
121 +                using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage)))
122 +                {
123 +                    XmlSerializer serializer = new XmlSerializer(typeof(GetCustomersCall.Response));
124 +                    set = (GetCustomersCall.Response)serializer.Deserialize(ms);                 
125 +                }
126 +            }
127 +            catch (Exception ex)
128 +            {
129 +                #region handle exception
130 +                set.Status = new BusinessEntities.LabRestService.GetCustomersCall.ResponseStatus();
131 +                set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString();               
132 +                set.Status.ErrorMessage = "Exception occurred in GetCustomers (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.Message;
133 +                ex.Data.Add("WebserviceUsername", WebserviceUsername);
134 +                ex.Data.Add("WebservicePassword", WebservicePassword);
135 +                ex.Data.Add("CustomerUsername", CustomerUsername);
136 +                ExceptionHandler.HandleException(ex);
137 +                #endregion
138 +            }
139 +            return set;
140 +        }
141 +{{/code}}
106 106  
107 - try
108 -
109 - {
110 -
111 -
112 - var content = new FormUrlEncodedContent(new[]
113 -
114 - {
115 -
116 - new KeyValuePair<string, string>("userName", WebserviceUsername),
117 -
118 - new KeyValuePair<string, string>("password", WebservicePassword),
119 -
120 - new KeyValuePair<string, string>("customerUsername", CustomerUsername),
121 -
122 - });
123 -
124 -
125 - HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetCustomers", content).Result;
126 -
127 - response.EnsureSuccessStatusCode();
128 -
129 - string responseMessage = response.Content.ReadAsStringAsync().Result;
130 -
131 -
132 - if (string.IsNullOrEmpty(responseMessage))
133 -
134 - {
135 -
136 - throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " / GetCustomers" + "]");
137 -
138 - }
139 -
140 - using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~)
141 -
142 - {
143 -
144 - XmlSerializer serializer = new XmlSerializer(typeof(GetCustomersCall.Response));
145 -
146 - set = (GetCustomersCall.Response)serializer.Deserialize(ms);                  
147 -
148 - }
149 -
150 -
151 - }
152 -
153 - catch (Exception ex)
154 -
155 - {
156 -
157 - #region handle exception
158 -
159 -
160 - set.Status = new BusinessEntities.LabRestService.GetCustomersCall.ResponseStatus();
161 -
162 - set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString();              
163 -
164 - set.Status.ErrorMessage = "Exception occurred in GetCustomers (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.Message;
165 -
166 -
167 - ex.Data.Add("WebserviceUsername", WebserviceUsername);
168 -
169 - ex.Data.Add("WebservicePassword", WebservicePassword);
170 -
171 - ex.Data.Add("CustomerUsername", CustomerUsername);
172 -
173 -
174 - ExceptionHandler.HandleException(ex);
175 -
176 - #endregion
177 -
178 - }
179 -
180 -
181 - return set;
182 -
183 - }
143 +
184 184  )))
185 185  
186 186  |(((
... ... @@ -224,7 +224,6 @@
224 224  </Response>
225 225  )))
226 226  
227 -
228 228  == Get Products (POST) ==
229 229  
230 230  === Request example ===
... ... @@ -387,7 +387,6 @@
387 387  )))
388 388  
389 389  
390 -
391 391  = Gebruikersaccount controleren. =
392 392  
393 393  
... ... @@ -952,7 +952,6 @@
952 952  )))
953 953  
954 954  
955 -
956 956  = Get Order status and Results =
957 957  
958 958  == Oplossing/Design ==
... ... @@ -1122,5 +1122,3 @@
1122 1122  
1123 1123  
1124 1124  
1125 -
1126 -