This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
web-integration:c-sharp-example [2019/08/05 11:22] tjotov |
web-integration:c-sharp-example [2019/08/05 11:27] (current) tjotov |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| C# relies on Web services for ADUCID - or WSA, see [[web-integration: | C# relies on Web services for ADUCID - or WSA, see [[web-integration: | ||
| - | === Import WSDL into your project in Visual Studio. | + | Import WSDL into your project in Visual Studio. |
| Create an instance of **AducidApiJsonServiceClient**. | Create an instance of **AducidApiJsonServiceClient**. | ||
| Line 56: | Line 56: | ||
| Just simple " | Just simple " | ||
| <sxh csharp> | <sxh csharp> | ||
| - | //We have to " | + | |
| var aducid = new AducidApiServiceClient(); | var aducid = new AducidApiServiceClient(); | ||
| context.Response.ContentType = " | context.Response.ContentType = " | ||
| Line 89: | Line 89: | ||
| <sxh csharp> | <sxh csharp> | ||
| - | var aducid = new AducidApiJsonServiceClient(); | + | |
| - | //read authId from you session | + | |
| - | string authId = (string)context.Session[" | + | var queryParsed = HttpUtility.ParseQueryString(query); |
| - | var aducidResult = aducid.getResult(authId, | + | var id = queryParsed[" |
| - | //parse json | + | |
| - | dynamic aducidResultObj = JsonConvert.DeserializeObject(aducidResult); | + | string authId = (string)context.Session[id]; |
| - | // | + | context.Response.ContentType = "application/ |
| - | var udi = aducidResultObj.data.userDatabaseIndex; | + | try |
| - | //key to further ADUCID operetions on user object | + | { |
| - | string | + | //call AIM to get operation result |
| - | //prepare response | + | |
| - | var response = aducid.endAuthenticationSession(authId, | + | // |
| - | context.Response.ContentType = "text/plain"; | + | var udi = aducidResult.userDatabaseIndex; |
| - | //OK do something with your session | + | //authKey |
| - | //... | + | |
| - | //send response | + | //finalize authentication and get respoonse form Web API |
| - | context.Response.Write(response); | + | var response = aducid.endAuthenticationSession(authId, |
| + | // | ||
| + | FormsAuthentication.SetAuthCookie(" | ||
| + | //send Web API the result - by default it will redirect to URI we provided earlier; for iOS PEIG opens this URI directly | ||
| + | | ||
| + | } | ||
| + | catch (System.ServiceModel.FaultException e) | ||
| + | { | ||
| + | | ||
| + | var msgFault = e.CreateMessageFault(); | ||
| + | var errorResult = msgFault.GetDetail< | ||
| + | //get error as JSON | ||
| + | var response | ||
| + | //send JSON to Web API | ||
| + | context.Response.Write(response); | ||
| + | } | ||
| </ | </ | ||
| === Prepare a web page === | === Prepare a web page === | ||
| - | This page should contain [[integration-api:start|ADUCID Integration | + | This page should contain [[web-integration:client-side|Client |
| Provide start, check and proxy Url. | Provide start, check and proxy Url. | ||
| - | < | ||
| - | | ||
| - | | ||
| - | | ||
| - | </ | ||
| Override what should be done after authentication / operation: | Override what should be done after authentication / operation: | ||
| - | <sxh> | + | < |
| - | | + | <script type=" |
| + | var aducid = new ADUCID(); | ||
| + | |||
| + | $(document).ready(function () { | ||
| + | aducid.setAuthentication(); | ||
| + | //operation start URL | ||
| + | aducid.setStartOperationUrl(" | ||
| + | //operation check URL | ||
| + | aducid.setResultOperationUrl(" | ||
| + | //proxy helper URL | ||
| + | aducid.setProxyUrl(" | ||
| + | |||
| + | //text under QR code | ||
| + | aducid.showQRHint = function (param) { | ||
| + | $('# | ||
| + | } | ||
| + | |||
| + | //running operation texr | ||
| + | aducid.showRunningHint = function (param) { | ||
| + | $('# | ||
| + | } | ||
| + | |||
| + | //called when auth finished (except iOS) | ||
| + | | ||
| + | alert(" | ||
| if (result.status == " | if (result.status == " | ||
| - | | + | location.href = result.redirect; |
| - | //location.reload(); | + | |
| } | } | ||
| else { | else { | ||
| - | | + | |
| } | } | ||
| } | } | ||
| + | |||
| + | //handle PEIG not installed error | ||
| + | aducid.showPeigError = function () { | ||
| + | showDialog(" | ||
| + | location.reload(); | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | //handle communication or other error | ||
| + | aducid.handleError = function (result) { | ||
| + | showDialog(" | ||
| + | location.href = result.redirect; | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | //GUI mapping | ||
| + | //button associated to start auth | ||
| + | aducid.setButton($("# | ||
| + | //locatino of QR code img | ||
| + | aducid.setQrCode($("# | ||
| + | //location of text under QR code | ||
| + | aducid.setQrHint($("# | ||
| + | |||
| + | //start; false as we wait for button click or qr scan | ||
| + | aducid.init(false); | ||
| + | }); | ||
| + | </ | ||
| </ | </ | ||
| Line 133: | Line 193: | ||
| <sxh html> | <sxh html> | ||
| - | < | + | <div class=" |
| + | | ||
| <div class=" | <div class=" | ||
| <div class=" | <div class=" | ||
| Line 159: | Line 220: | ||
| </ | </ | ||
| </ | </ | ||
| + | </ | ||
| </ | </ | ||