WCF: Configuring Known Types

I guess I have found the answer now. The configuration file I posted above looks like this: <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <system.runtime.serialization> <dataContractSerializer> <declaredTypes> <add type=”Person, WCFWithNoLibrary, Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”> <knownType type=”Employee, WCFWithNoLibrary, Version=1.0.0.0,Culture=neutral, PublicKeyToken=null” /> </add> </declaredTypes> </dataContractSerializer> </system.runtime.serialization> <system.serviceModel> ……. </system.serviceModel> </configuration> What I just added was, the Namespace of the Person class and … Read more

Connecting via named pipe from windows service (session#0) to desktop app (session #1)

An easier solution might be to use a WCF duplex contract with the Windows service hosting the WCF service. The client App would call an operation on the service to register itself, when it starts up. The Ping would then be an operation invoked periodically by the service on the client’s callback contract, to which … Read more

WCF + REST: Where is the request data?

This unfortunately isn’t supported- we had a similar need, and did it by calling internal members with reflection. We just use it in an error handler (so we can dump the raw request), but it works OK. I wouldn’t recommend it for a system you don’t own and operate though (eg, don’t ship this code … Read more

WSDL-first approach: How to specify different names for wsdl:port and wsdl:binding?

You can try to implement IWsdlExportExtension and in ExportEndpoint modify wsdl:port/@name. Then implement IEndpointBehavior which will add your extension to an endpoint. To use your new behavior you have two choices: Add behavior from code. When service is hosted in IIS you have to create custom ServiceHost and ServiceHostFactory. In self hosting you can just … Read more

How to serialize Dictionary through WCF?

WCF only serializes structure, because what ends up on the wire must be self-contained enough to be useful for any client, not just .NET clients. Some client developed on a different platform may not share the concept of a ‘dictionary’, so it would be too constraining to serialize a Dictionary to a representation that carries … Read more

Invoking WCF service method through a browser

You would need to add WebGetAttribute to your method like following sample [OperationContract] [WebGet(UriTemplate = “/placesList/{userId}”, ResponseFormat = WebMessageFormat.Xml)] List<Places> GetAllPlacesForUser(String userId) { string xml = “”; // build xml here return xml; } Now in the browser, you could invoke the method like this http://localhost:8085/GeoPlacesDataService/placesList/10 where 10 is the userId parameter. Note: In order … Read more

How can I return json from my WCF rest service (.NET 4), using Json.Net, without it being a string, wrapped in quotes?

I finally figured out a solution to this. It’s not what I would have preferred (which would be to return the specific object type, and somehow instruct WCF to use a Json.Net serializer, instead of the DataContractJsonSerializer), but it is working great, and it’s simple and clear. Extending my contrived example using this new solution: … Read more