Web Services/WCF

Serialization error when property is declared as base class, but populated by derived class

I've receive quite generic error Message : Type 'MyclassType' with data contract name 'MyclassType:http://schemas... is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.Type : System.Runtime.Serializatio... mscorlib, Version=4.0.0.0, Culture=neutral, ......

Response for REST method was truncated because default MaxItemsInObjectGraph was not big enough.

We have a REST service with attributes [WebGet(UriTemplate ="...", BodyStyle =WebMessageBodyStyle.Bare, ResponseFormat =WebMessageFormat.Xml)]Norm... it worked fine. But for particular data it has a huge response that was truncated. The size returned in a few attempts in IE browser was 2196456, in Chrome slightly different 2195397.After a search in google I found http://forums.asp.net/post/... that has a number of suggestions. For WCF service that will transfer large amount of data in ......

WCF Transactions are not supported by Azure.

We have a service operation, for which it is very important to ensure that a client receives the status, that was determined at the end of operation.If client does receive the response, the server status should be "completed". Otherwise (in case of communication error), server status should be rollback and stay as "pending". The possible technical solutions were discussed and WCF Transactions support with 2PC(two phase commit) was selected. We implemented service operation with transaction commit/rollback ......

maxItemsInObjectGraph limit required to be changed for server and client

We have a wcf service, that expects to return a huge XML data. It worked ok in testing, but in production it failed with error "Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota."The MSDN article about dataContractSerializer xml configuration element correctly describes maxItemsInObjectGraph attribute default as 65536, but documentation for of the DataContractSerializer.MaxI... ......

Using interfaces in DataContracts for WCF service versioning.

We are implementing WCF Service versioning after having problems with enums in response ( Do not expose enum in WCF response )I found that we need rigorously follow the recommendations "Versioning When Schema Validation Is Not Required" from msdn article:Best Practices: Data Contract VersioningInitially I've ignored the recommendation "Do not attempt to version data contracts by type inheritance" and failed to generate backward compatible XML.Reading the documentation I've noticed in Service Versioning ......

ResolveUrl() from WCF service

I wanted to ResolveUrl() from WCF service and foundhttp://www.west-wind.c... .However the function assumes that the call is synchronous, in asynchronous call (e.g called from TPL task) HttpContext.Current==null.I had to split my asynchronous method into two-a long asynchronous one, invoked as task and generating relative URL and a post-task, that is calling wwWebUtils.ResolveServerUrl... http://www.codeproject.com/... ......

Do not expose enum in WCF response

We had a backward compatibility problem in WCF client, when in Service application a new value was added to one of enums. We discussed different ways to avoid this backward compatibility issues, and I found recommendation do not expose enum in wcf response in http://stackoverflow.com/a/... is still required to create new versions of our service interfaces to replace each enum fields with string field, that expects only documented values, and describe, what should be default behavior, ......

Custom HTTP response header to identify server in a farm.

We wanted to follow recommendation from http://omaralzabir.com/best... to“add “From” header and set the server name. I do this on each webserver and specify different names on each box. It’s handy to see from which servers requests are being served. When you are trying to troubleshoot load balancing issues, it comes handy to see if a particular server is sending requests” However one of the client of our rest service reported that From value in the response ......

Make WCF services to help use the same namespace when called from WCF Clients

We have two services, that can be called independently, but also can be used together. They have some common types, and if they called together, default Visual Studio proxy generation will create the same types in different namespaces. There are multiple articles, that recommend to use command line SvcUtil instead of Visual Studio IDE. The article How to reuse types across service endpoints suggests on client side manually update Reference.svcmap to include multiple <MetadataSources> and NamespaceMappings ......

Use WCF Binary Encoding when Host in IIS6

I wanted to replace .Net Remoting calls with WCF. Article “From .NET Remoting to the Windows Communication Foundation (WCF)” was very useful for me. It was misleading reference to Attribute ReturnUnknownExceptionsAsFa... which doesn’t exist any more.It has been changed to IncludeExceptionDetailInFau... I wanted to use WCF Binary Encoding when Host in Windows 2003 Server(IIS6) instead of text encoding, that is coming out-of-the-box I found the blog WCF: Enable Binary Encoding Over Http and literally ......

WCF: Suppress authentication for testing on different domain.

I have a WCF service and client, which worked fine, when I debug it on my local machine. However when I deployed the service to test server on the different domain. I've started to receive error System.ServiceModel.Securit... The caller was not authenticated by the service. ---> System.ServiceModel.FaultEx... The request for security token could not be satisfied because authentication failed. I've found a few similar recommendations, e.g. http://community.discountas... ......

OutOfMemoryException in Microsoft WSE 3.0 Diagnostics.TraceInputFilter

We are still using Microsoft WSE 3.0 and on test server started to get Event Type: Error Event Source: Microsoft WSE 3.0 WSE054: An error occurred during the operation of the TraceInputFilter: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.String.GetStringForS... value, Int32 startIndex, Int32 length, Int32 capacity) at System.Text.StringBuilder.G... tid) at System.Text.StringBuilder.s... value) ......

Specify Expect100Continue=false in Web Service client.

The Web Service Provider that we are using recommends NOT send Expect100Continue header. The specifying static value System.Net.ServicePointMana... is not good, because some other providers may prefer to use the header. In the haacked's "HttpWebRequest and the Expect: 100-continue Header Problem" post comment of Mirronelli Jun 02, 2005 6:22 AM suggest to specify webRequest.ServicePoint.Exp... = false; for each webRequest. If I am using web service(derived from ......

Attempt to get Visio Class Diagrams from VS XSD files.

I wanted to have a diagram from .Net Dataset (stored as XSD) and include elements from XSD generated from WCF service. I found that is not supported by MS tools. Dataset Designer doesn't have any export facility.XSD files generated from WCF service, do not have any graphical interface at all. I ended up with manually drawing in Visio objects used by WCF service and merge PrintScreens from VS Dataset Designer and Visio Class Diagram in Paint.Not a nice solution. I've posted a suggestion "Ability to ......

Could not load type 'System.ServiceModel.Configuration.BindingsSectionGroup'

After installing .Net 3.5 SP1 on the existing server, that runs .Net 2.0, I've got the exception: Source : mscorlib Message : An error occurred creating the configuration section handler for system.serviceModel/bindings: Could not load type 'System.ServiceModel.Config... from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934... Filename : c:\WINDOWS\Microsoft.NET\Fr... Line : 100 Errors : ......

Use WCF Message Logging

The post based on How to enable WCF tracing article Open WCF Service Configuration Editor under VS 2008 Tools menu or directly from installation folder (typically C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SvcCo... - subfolder v6.0 can be different depending on which version of Windows SDK has been installed) To enable WCF message logging Click the Diagnostics node, and expand it. Enable Message Logging on the right Tab To edit Message Logging settings, click the Message Logging ......

Generate C# class from XSD file.

I have an existing C# file, generated a long time ago from XSD definition. The XSD files were changed, and proxy class should be regenerated. I've tried to use XML Schema Definition Tool (Xsd.exe) to generate C# class, but it returned the error: "The datatype is missing". I've actually have two XSD files -outer and imported Thanks to the post: XSD.exe is kicking my butt, man...redux , it pointed me to specify all necessary files on the commandline. Note that name of generated file is combined from ......

Call Synchronous Web Services Methods Asynchronously

I need to asynchronously call a few web services at the same time. VS 2005/2008 Web services proxy generator creates several proxy class methods , including synchronous MyWebMethod(parameters) and asynchronous pair BeginMyWebMethod(parameters) and EndMyWebMethod(parameters) The way to use Begin/End methods is described in article "Calling Web Services Asynchronously " Even if I am going to use asynchronous method in the real application, for unit testing(including TestHarness ) it is much easier ......

Dynamic URL Web Service URL is not loaded from applicationSettings section in Console application

I have a class library DLL, that has client web services reference. The reference is dynamic and in generated app.config the URL is listed inside <applicationSettings>. I am using the class from web Application(WAP) and by copying <..Properties.Settings> to web.config I am able to change the URL just by modifying value in web.config(I even wrote helper class to Update Dynamic Web reference URLs Diring Installation in Visual Studio 2005). The approach is well described in How to share ......

Unable to run WSDL.exe against Example from Web Services Description Language (WSDL) 1.1

I need to create WSDL file for RPC/Encoding soap implementation. To learn how to create the WSDL I took an Example 5. SOAP binding of request-response RPC operation over HTTP from Web Services Description Language (WSDL) 1.1 specification and tried to run WSDL.exe for the file. I have to fix couple simple errors 1. removed wsdl: from wsdl:arrayType 2. Changed StockQuoteBinding to StockQuoteSoapBinding in <port name="StockQuotePort" binding="tns:StockQuoteBind... And then I've got the error: ......

Full Web Services/WCF Archive

«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456