WCF
There are 6 entries for the tag
WCF
Overview
In a previous post, I proposed a means of deserializing JSON returned from calls to ClientScript endpoints such as XML WebServices decorated with [ScriptService] or [ScriptMethod] attributes, Ajax-enabled WCF Services and WCF services created with WebScriptServiceHostFactory.
The use case that prompted this requirement is testing endpoints called by client-side JavaScript. Calling WebScript enpoints in managed code using HttpWebRequest is easy, the trick is to specify content-type 'application/json'. And this is where the problems start.
Problem Domain
When a WebScript endpoint responds to a request with content-type 'application/json' it understandably assumes that it is being called from JavaScript and, as of 3.5sp1, wraps the actual...
Mixing and matching security to get something like this locked down and providing the desired exposure might be challenging but I didn't offer to solve that in the title, did I?
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webScriptBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Salient.ScriptModel.Services.DualServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="Salient.ScriptModel.Services.DualServiceBehavior" name="Salient.ScriptModel.Services.DualService">
<endpoint...
While writing a barebones js lib to provide intellisense enabled access to WCF JSON endpoints using the /js and /jsdebug mapped endpoints, I came across a bug in System.Web.Script.Services.ClientProxyGenerator.
I was wondering why all of the enums that were generated were marked as Flag when they clearly were not. The reason this is an issue is that if you want to .parse or .toString an enum and it is incorrectly marked Flag your results are going to be wrong.
The ramifications of this can vary from annoying to disasterous. Say you want to display people friendly value of an enum returned from a...
I have been struggling with the seemingly unbeatable UTCness of js Date.getTime in respect to dealing with dates going between javascript and wcf. I tried adding the offset/60/1000, munging local times, closing one eye and sticking out my tongue and nothing. nothing. The server was always getting a utc long and treating it as a local.
I have been following Rick's saga with wcf dates r.e. ajax and gave his solutions a go and got pleasant results with the .parseWithDate() tweak to json2.js but could not get results with the .stringifyWcf(). Got UTC with no offset no matter how much attention...
Download the sample source code for this post here
In this post I will attempt to describe what I learned while working out how to separate the concerns of a WCF service layer from those of a presentation layer and vice-versa while using a redistributable client assembly and NOT using client proxy code generated by Visual Studio 'Add Service Reference' or svcutil.exe.
The code and scenarios do not necessarily represent best practices and will most likely offend some purists but I do believe that the topics covered represent real world challenges and may provide some insight into some not-so-obvious aspects of...
Doing interop with an ASP.NET ScriptService in JavaScript is simple, just deserialize the payload, e.g. result.d.
But if you are consuming with managed code it gets a bit tricky.
The 3.5 stack wraps the payload in a 'd' container making deserialization to a similarly shaped type or a type in a shared library (if you are using a shared library, why use JSON? There are reasons... ;-p) impossible using any of the ms serializers.
My solution is to use Newtonsoft's JSON.NET with a simple generic helper class to unwrap the payload..
public class AjaxWrapper<T>
{
public T d;
}
and then deserialize...