Where to host WCF service for CRM Online 2016? - dynamics-crm-online

I have created a WCF service, which will be consumed by / called from CRM 2016 Online Case Form (using jscript/ajax call).
Where should I host the WCF service?

You are responsible for deciding where to host the service and configuring/programming for single sign-on (if you need security and want to avoid additional password prompts.)
The most logical place to run this would be in Azure: Deploying WCF Service on Windows Azure

Related

Dynamics CRM 2016 On-Premises API Authentication

Our setup consists of on-premises CRM 2016 in IFD configuration with ADFS. We have several custom web apps that are embedded in iframes in CRM as well. Our web apps are MVC running in IIS on .NET 4.7 and use the WS-Federation IIS module for authentication. This provides a pretty seemless experience where the embedded application does the redirect to and from ADFS to authenticate the user after they're already logged into CRM.
Our applications also call APIs we have created, which in turn make calls to Dynamics CRM web API using OData. Our APIs are setup to make calls to the CRM web API as a specific user chosen at deployment (it's a bit ugly, but it works). This causes issues associating created entities with the actual user, as CRM considers them created by the user in the API deployment. We need to fix that so that the user authentication is passed from our web application to our API and then to the CRM OData API.
From searching this site and other resources, I have determined this is not possible with WS-Federation and I would need to use OIDC. But, all the documentation that I have found about using OIDC in this manner has involve using Azure Active Directory and Dynamics 365, which does not apply in my scenario. I haven't found any information for the configuration of a local CRM 2016 instance or ADFS.
How is this accomplished for an all on-premises deployment?
To impersonate a user, set the CallerId property on an instance of
OrganizationServiceProxy before calling the service’s Web methods.
via https://learn.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/org-service/impersonate-another-user
Or
To impersonate a user based on their systemuserid you can leverage
MSCRMCallerID with the corresponding guid value.
via https://learn.microsoft.com/en-us/powerapps/developer/data-platform/webapi/impersonate-another-user-web-api
Although I can't guarantee that it will work in version 8.1 and below.

Using NServiceBus in Partial Trust Application

We are trying to send NServiceBus messages from a Microsoft Dynamics CRM plugin and running into issues like this:
Attempt by security transparent method [Our_Namespace].GetStandardBus(System.String)' to access security critical type 'NServiceBus.IBus' failed at [Our_Namespace].GetStandardBus(String endpointName)
The CRM plugins are running in the sandbox which means they are running as partial trust in IIS and we really want to keep it that way.
So my question is, is it possible to access NServiceBus from an IIS partial trust application?
Thanks,
Mark
Check out the Dynamics Adapter for NServiceBus:
https://github.com/ParticularLabs/NServiceBus.DynamicsAdapter
... contains an example application that demonstrates bi-directional integration between cloud hosted Dynamics 365 2016 and an on-premises NServiceBus system using Azure Service Bus Queues.

How do I secure an odata service running on windows Azure

I am hosting odata service on windows azure platform. How do I authenticate client/user within windows azure platform before they can access the odata service?
Thanks,
In the WCF Data Sevice Team´s blog there is a huge entry splitted in 8 parts where they deatils all about authentication:
http://blogs.msdn.com/b/astoriateam/archive/2010/05/10/odata-and-authentication-part-1.aspx

wcf windows service interaction

I have a windows service in which i host a wcf service.
What is the best approach to control the windows service via the wcf service? I already created the interfaces for the wcf service, but I have no idea how to interact with the windows service's classes and functions.
just to check that I'm understanding your problem correctly - you want to run a wcf service, so you create a windows service to host it, and you want your desktop client to be able to control the windows service (that's hosting the wcf service) by talking to the wcf service?
If that's the case, what is it that you're trying to do with the windows service? In some of the work I've done, I've set up the server such that there's the windows service hosting all the wcf services I want to run, and in order to interact with that windows service remotely (e.g. starting/stopping/restarting) I have another service running on the server (usually baked into the Amazon instance image so it's running on every new server that gets brought up) which my remote client can talk to instead. That way I have a means to trigger a service restart on all my servers without having to manually connect/remote desktop to each server. Of course, the second wcf service is secured by some means so it can't be exploited easily.
Is that the sort of thing you're looking to do?

Writing Windows service in WCF

I want to write windows service in wcf After searching a lot I only found were tutorials of writing webservice in wcf not windows service.
Can any one please provide a link to any tutorial which explains how to write windows service in WCF
Windows services are executables. WCF applications are, generally, web services, exposed over a URI. You can host a WCF application within a windows service, not the other way around.
To create a Windows service in C#, follow the step-by-step here. To make your Windows service WCF-enabled, if you will, create the System.ServiceModel.ServiceHost instance that will host your WCF service inside the OnStart() callback.
Good answers all of them. Just a quick note... implement your WCF service in a class library (dll) so you can then host it anywhere you like (IIS, Console App, or Windows Service).
I'd recommend starting from a console application, after your service works as expected, create a Windows Service, add a reference to you library and start the service (WCF) from there (Windows Service)
Edit: I just assumed you meant create a WCF service hosted as a Windows Service, if that's not the case please ignore my answer.
Create your WCF service as normal, create a Windows Service and then use ServiceHost to self-host the WCF service in your Windows Service. See this MSDN page for more information about self-hosting WCF services.

Resources