0

Hi created my service using http://ntieref.codeplex.com/ n-tier entity framework.

The service the generator created uses wcf and wsHttpBinding. It uses windows authentication and the program created works fine when the user is logged in the Domain (as it should). My problem is when I am trying to connect from "outside". I could not find a way to pass something like this:

client.ClientCredentials.UserName.UserName = "SomeUserName";
client.ClientCredentials.UserName.Password = "WrongPassword";

thats why my call fails with the user not validated.

My question is specific to n-tier entity framework (http://ntieref.codeplex.com/) with the default generated. That's why I am not posting configs. If some one has experience on this framework please help. I would like to also expose some functions of my own written on the server to the clients (beyond the entity generated functionality) (e.g. a login function that will return some custom class after validation) without breaking the existing functionality.

Where should I write my code ?

EWit
  • 1,954
  • 13
  • 22
  • 19
voulgeor
  • 3
  • 1

1 Answers1

0

WCF Endpoint Configuration

The n-tier entity framework generates plain vanilla WCF services which can be exposed through any WCF endpoints. All you need to do is setting-up corresponding endpoint configurations in your config.


Custom Service Methods

Both, service contracts and implementation are generated as partial interfaces and classes. This allows to add additional custom services methods as required.

ChristofSenn
  • 337
  • 2
  • 6
  • thanks for your answer but I dont want to change the wcf config I just want to be able to connect someone from outside mainly for demoing reasons so I want to know how can I pass windows credentials as the client.domain doesnt expose cliend.ClientCredentials. As for the custom service methods in what module should i put my code? on the dataservice of the Server.domain.service module ? could you please post an example ? Sorry for my dump questions as is my first trip to wcf programming – voulgeor Mar 26 '14 at 09:51
  • If I understand correctly your “outside” client is not part of the same Active Directory Domain as the server is and therefore Windows authentication cannot be used. For using username and password you need to change your WCF binding configuration to used basic authentication. Have a look at http://msdn.microsoft.com/en-us/library/aa354513.aspx or google for WCF and basic authentication. – ChristofSenn Mar 26 '14 at 21:59
  • Thanks. any advice in what module should i put my Custom Service Methods so can be exposed to the client side? – voulgeor Mar 28 '14 at 13:41
  • Sure, custom service methods go to `.Common.Domain.Service` for the interface (service contract) and `.Server.Domain.Service` for service implementation. In both of these components you find partial interfaces/classes generated by the n-tier entity framework. Make sure to add custom parts into separate C# files using partial classes to make sure it doesn’t get lost when the framework re-generates any source code. – ChristofSenn Mar 29 '14 at 10:50
  • is there a way to consume your services for a non .net client like an php site on an Apache server? – voulgeor Jun 15 '14 at 14:41
  • @voulgeor you have to put the http-authentication header inside the request of the client like in this example for angularjs http://stackoverflow.com/questions/20997841/basic-authentication-via-angular-why-is-this-throwing-error-401 – Sebastian Jun 25 '14 at 11:53
  • @voulgeor N-Tier Entity Framework generates plain WCF services, hence you can technically expose them via http endpoint and consume with any soap capable client. However, you'd lose a lot of the power the framework provides for properly maintain entity status on client-side (e.g. change-tracking, data validation, merge-back after saving, merge in-memory data with sub-sequent requests, etc.) – ChristofSenn Jun 25 '14 at 23:05