| www.leastprivilege.com - Hosting WCF Services in ASP.NET - The Survival Guide |
Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts
Sunday, March 07, 2010
Monday, August 24, 2009
No connection could be made because the target machine actively refused it...
| Just a self-reminder... Could be caused by WCF security configurations. Either set Binding→Security→Mode→None or if Mode is Transport - then add Windows credentials of user running the service in security config section. |
Wednesday, August 12, 2009
The server has rejected the client credentials - WCF Exception
| Control Panel→Administrative Tools→Local Security Policy→Local Policies→User Rights Assignment→Access this computer from the network Now add Authenticated Users if your services runs as an application or Network Service if it's service. |
Wednesday, June 17, 2009
Howto: publish metadata for net.tcp endpoint and add reference to WCF service hosted in process/service/console
|
Wednesday, October 10, 2007
How to create WCF service proxy without publishing mex endpoint #2
| Important update to my previous article: if your service is defined inside of a namespace - you must specify the namespace using /serviceName option during the 1st step (WSDL and XSD creation). Updated step #1 example: svcutil /serviceName:MyNamespace.MyService MyServiceSvc.exe /reference:SomeReference.dll If you'll miss specification of the namespace - resulting proxy code would be wrong (including even endpoing binding defintion). |
Sunday, August 19, 2007
How to create WCF service proxy without publishing mex endpoint
| Some time ago I needed to create WCF service proxy, while I don't wanted to expose and publish MEX endpoint for it (and then generate the proxy from its wsdl). Strangely, but I didn't found any clue on how to do it in the Google depths. Even MSDN articles (1 and 2) devoted to the SvcUtil doesn't mention it in a straightforward way. Here is how to do it: 1) Create WSDL and XSD definitions for your service. Use following command: svcutil /serviceName:MyService.MyServiceClass MyServiceAssembly.exe /reference:MyServiceContracts.dll (You'll need to reference additional assemblies related to the service, like I did with MyServiceContracts.dll) 2) Generate proxies and corresponding client WCF configuration in .config file: svcutil *.wsdl *.xsd /language:C# |
Wednesday, August 15, 2007
In order to add an endpoint to the service MyService, a non-empty contract name must be specified.
| Are you getting InvalidOperationException while creating ServiceHost for your service and getting message in style of "In order to add an endpoint to the service 'MyService', a non-empty contract name must be specified."? the probable reason is that you've missed contract definition in one of it's endpoints. Go to the endpoints list in your .config file and check that each endpoint has 'contract="MyContracts.IMyInterface"' tag. |
Wednesday, August 08, 2007
WCF Performance
| Some time ago I've developed a Comet infrastructure for the ASP.NET Ajax. As part of its possibilities - it enables to serialize server-side objects and stream them to the handling function at client side. It was working like a breeze, until Ive streamed some object with Date field, say something like that: public class TestMessage { public string _s1 = "s1"; public int _i1 = 1; public DateTime _t1 = DateTime.Now; } Now, an instance of this TestMessage was correctly deserialized into JS object, exclude its DateTime fields, which was appearing in following form: {...} _i1: 1 _s1: "s1" _t1: "/Date(777)/" If youre affected by similar problem here is the reason: 1) JSON representation for the string was changed from @777@ to \/777\/ in the latest Ajax release (to prevent serialization of strings that looks like date into Date format), where 777 is num of milliseconds since January 1, 1970 UTC. 2) Currently - at the server side DateTime object is serialized as "_t1":"\/Date(777)\/" 3) If you stream it as-is to the client-side JS recognizes single \ as escape character and your date actually became /Date(777)/, which is wrong format for deserialization. So, if you want to stream your objects correctly you here is small RegEx-based utility Ive did for it: private static class ReplaceDateOrchestrationRegularExpression { private const string _regex = "(? private static readonly RegexOptions _options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase); public static readonly Regex Expression = new Regex(_regex, _options); public const string ReplaceOptions = @"${prefix}${firstDateSlash}\${body}${secondDateSlash}\${postfix}"; } private static string ConvertToClientSideJson( string jsonedArgument ) { return ReplaceDateOrchestrationRegularExpression.Expression.Replace( jsonedArgument, ReplaceDateOrchestrationRegularExpression.ReplaceOptions); } |
Subscribe to:
Posts (Atom)