Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 852483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:36:09+00:00 2026-05-15T07:36:09+00:00

In our production environment, our WCF services are serialized with the XMLSerializer. To do

  • 0

In our production environment, our WCF services are serialized with the XMLSerializer. To do so our service interfaces have the [XMLSerializerFormat] attribute. Now, we need to change to DataContractSerializer but we must stay compatible with our existing clients. Therefore, we have to expose each service with both serializers.

We have one constraint: we don’t want to redefine each contract interface twice, we have 50 services contract interfaces and we don’t want to have

IIncidentServiceXml 
IIncidentServiceDCS
IEmployeeServiceXml 
IEmployeeServiceDCS
IContractServiceXml 
IContractServiceDCS

How can we do that?


More info

This is a description of what we have tried so far but I’m willing to try completely different approaches:

We tried to create all the endpoints by code in our own ServiceHostFactory class. Basically we create each endpoint twice. The problem is that at runtime, WCF complains that the service has two endpoints with the same contact name but with different ContractDescription instances. The message says we should use different contract names or reuse the same ContractDescription instance.

Other attempt:

We also tried to do it by using different Namespaces for each ContractDescription instance. That way we would keep the same contract interface (IIncidentService) but with two different namespaces:

http://ourcompany/XML/IIncidentService
http://ourcompany/DCS/IIncidentService

With that we were able to get farther but the service crashed with a weird exception:

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.XmlSerializerOperationBehavior
contract: http://ourcompany.cs/XML:IUserServiceWCF ----> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.ServiceModel.Description.XmlSerializerMessageContractExporter.ExportFaults(Object state)
   at System.ServiceModel.Description.MessageContractExporter.ExportMessageContract()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.System.ServiceModel.Description.IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext contractContext)
   at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:36:15+00:00Added an answer on May 15, 2026 at 7:36 am

    Short answer is, you can’t, for exactly the reason your error message said, you can’t have too endpoints with the same name which effectively you are trying to do. I think you will have to do exactly what you say you don’t want to.

    This might be your only option

    The problem is that to specify a
    service is to use the XmlSerializer
    you need to declare the
    [XmlSerializerFormat] attribute on the
    service or the contract. Well since
    we want to use the same for both
    endpoints we can’t place it there, so
    we are left with placing it on the
    contract. However, when it boils down
    to it, both endpoints are using the
    same service and vicariously the same
    contract right?

    Well, it doesn’t have to be so. You
    could have a contract A derive from
    contract B, then have the service
    implement contract A such that
    everything in both contracts is part
    of the service. For this example
    though, contract B will be our
    standard contract, and contract A will
    be an interface that just defines the
    [XmlSerializerFormat] attribute.

    But I can’t promise you that will work with your existing clients code without changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service which works perfectly when deployed in our dev and
We have a query that is taking around 5 sec on our production system,
We have an Sqlite DB on our Linux/PHP production webserver. What is the best
I have a WCF service and a Web application. Web application makes calls to
I have a simple WCF Web service. It's hosted on IIS under the default
I am creating solution and inside I have three projects: A WCF Service Library
Our production environment runs 3 32-Bit Java 6 JVMs on each Windows 2003 server.
We like our production environment with a restricted/unchangable schema -- the development side can
This exception peppers our production catalina logs on a simple 'getParameter()' call. WARNING: Parameters:
I work at a small company and our production system uses a hand-rolled RESTful

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.