Access WCF service behind Azure AD from Net core - wcf

I have a WCF Service (using HttpBasicBinding), it is a part of a WebApp (written with .Net Framework 4.8). WebApp is registered with Azure AD and thing works fine with the login. Now I want to access WCF from other WebApp (written with NET 6 and also register with Azure AD). I generated WCF Client using dotnet-svcutil, but it cannot connect to WCF service, because I don't know what to put in ClientCredentials/token/Bearer or something like this.
Page

You can using the Service Reference
find the name of the client class and operation you want to use. Reference.cs will contain a class that inherits from System.ServiceModel.ClientBase, with methods that can be used to call operations on the service.
You can refer to the following article:
https://learn.microsoft.com/en-us/dotnet/core/additional-tools/dotnet-svcutil-guide?tabs=dotnetsvcutil2x
https://www.thecodebuzz.com/consuming-wcf-web-services-in-net-core-using-global-tool/

Related

How do I add a WCF Service Reference for my .NET Core App (.NET Framework)

I'm only using a .net framework with it and I can add a pure c# project that contains the service reference - but I can't create a Service Client with this approach, it tells me it cannot find an endpoint with the proper values
(Contract, Endpoint name, both are identical to the endpoint I copied over to my web.config.)
Is there a specific procedure in which you can add a service reference when it comes to ASP .NET Core? or is it just like regular .NET Framework?
Thanks in advance.
There are multiple ways to access wcf service, If you have control over wcf service implementation side. you can change your service to restful wcf service. if you don't have access to that use seviceutil.exe to get proxy class and config file.
1. first copy code from proxy class.
2. second add class reference to your ASP.NET code behind.
Check how to use serviceutil.exe on google.
Also go to http://www.wcftutorial.net/ for more details.

Consuming a WCF REST Service in .NET?

I've this WCF service hosted in a Sharepoint 2010 web application. The WCF has been created using the following factory:
Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
As you can see this is creating a REST-type service. Because we needed to consume it client-side via jQuery.
Now we also need to access it from a .NET project (WinForms). I've tried adding the Service Reference in VS but it doesn't find anything. I guess that's because it's not a SOAP service right?
So how can I consume it in C# .NET project without breaking the existing jQuery support?
Yes, Add Service Reference does not work for WCF REST services. You have a couple of options here:
Add another endpoint to your service, a SOAP-based one, so that you'll be able to use Add Service Reference on your client. I don't know exactly what the MultipleBaseAddressWebServiceHostFactory does, but you could look how it creates its endpoint(s) and recreate that in another factory - and then add the additional SOAP endpoint
Another alternative is to share the interface definition (the service contract plus any existing data contracts) between the service implementation and the .NET client. Having that interface you can use the WebChannelFactory<T> to create a proxy to the REST service (like you'd have one for a SOAP service).

Consuming WCF Restful Service hosted by IIS

I have successfully deployed my WCF restful web service to IIS 7. I have verified that my service is working when I call it from a browser in IE via a something like "https://myserver/mservice.svc/postuser/JohnSmith" . The method is a POST and I have verified that my IIS configuration allows for POSTS.
My issue is as follows. We are using a 3rd party Software as a Service application that allows for external web service calls. It allows you to configure the URL "https://myserver/mservice.svc/postuser/" and then you can choose a parameter. When I call the web service from the external application, a 404 error is registered in IIS.
I think there must be some difference between the way I call my webservice "https://myserver/mservice.svc/postuser/JohnSmith" and the way the SAAS application is calling my external web service. The web service is attempting to pass the username, but I cannot detect how it is constructing this.
Do I need to write a web enabled front end for my web service that is hosted in IIS that can handle XML? I'm assuming this is how the SAAS application is trying to pass the username onto my web service.
Thank you all in advance for your ideas and help.

Using a console application to host WCF endpoints that expose asp.net ProfileService, ProfileService and RoleService

I've got an MVC web application that is used as an interface to a Console based app that exposes a bunch of ServiceHost/s using the net.pipe protocol.
I would like to use the asp.net membership/role/profile provider to manage my users and their roles and profile information (Inside the Console Application). I've done this in quite a few apps, but normally I reference these providers directly from the web application itself.
This is a good walk-through on doing pretty much what I would like, except I don't want to host the WCF service endpoints in IIS, but inside my console app - which will eventually become a windows service. When I try and host the ServiceHost through my console application I get the following error:
This service requires ASP.NET compatibility and must be hosted in IIS.
Either host the service in IIS with ASP.NET compatibility turned on in
web.config or set the
AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode
property to a value other than Required.
Now it seems that I won't be able to set that property to anything other than Required.
I've tried another route which is using the wrapper class/interface defined here for my authentication service, which I managed to get wired into in my MVC app without too much trouble, but this doesn't cover my Authorisation (using roles) or profile needs.
Has anyone got a solution to this, I can't be the only one trying to do this? I'm not

Using WCF authentication service for web application

I am using a WCF authentication service I set up with a web application. I have successfully set up and tested the AuthenticationService and RolesService. The web application can successfully call methods like ValidateUser and GetRolesForCurrentUser through the WCF services.
I want to integrate the WCF authentication service with my web.config and site.map. Do I need to write a custom provider, or is there some way I can modify the web.config of the web application to use the WCF authentication service as its membership provider?
This way I can set what roles have access to what directories based off the WCF authentication service.
Application Services are not intended as a replacement for the provider stack.
They are meant to augment and enable usage from context other than .aspx.
In most cases you may simply use the default provider stack (Membership/Roles/Profiles).
You simply need to pass the cookies that you get when you call 'Login' via app services around in the context of the service call.
See here for some more information about adding cookies to a WCF call.
If you are using AJAX to call the services, you don't have to do anything, simply authenticate via ajax and then call via ajax.
Skys answer doesn't seem to answer the question?
It seems to me that there is a genuine need to call the WCF AuthenticationService from an ASP.NET application?
Consider a three tier application where all database access is mandated to be performed by the application tier. There is a single database (data tier) containing business data as well as membership data.
I have written a three tier implementation whereby a custom MembershipProvider on the presentation tier invokes the AuthenticationService on the application tier which in turn runs my custom authentication routine.
I could quite easily create a custom WCF service (eg not AutheticationService) which does this authentication but I try to use .NET objects where possible.
it would be nice if I could tell ASP.NET to use the AutheticationService without needing a custom membership provider but I dont think this is possible?