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 4602448
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:59:11+00:00 2026-05-21T23:59:11+00:00

I have taken over development on a .NET WCF project. Among other things, the

  • 0

I have taken over development on a .NET WCF project. Among other things, the project contains 3 files:

  • IApi.cs <= Defining the interfaces
  • JsonApi.svc.cs <= Implementing interface for JSON
  • SoapApi.svc.cs <= Implementing interface for SOAP

The two implementation files are almost identical – at least all the code in the implementation of the methods is identical. I am quite new to WCF programming, but it strikes me as odd, that we need to duplicate the code, just to implement JSON as well as SOAP.

Is there a way to merge this into one implementation and let the framework decide if data is to be transported by SOAP or JSON?

/ Carsten

  • 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-21T23:59:12+00:00Added an answer on May 21, 2026 at 11:59 pm

    Defines two endpoints, with the same contract for your service implementation. Defines the first to use SOAP, then the second to use JSon :

    <service name="YourService">
        <endpoint address="rest"
                            binding="webHttpBinding"
                            contract="IYourService"
                          behaviorConfiguration="RestBehavior"/>
        <endpoint address="soap"
                            binding="wsHttpBinding"
                            contract="IYourService"/>
        <endpoint address="mex"
                            binding="mexHttpBinding"
                            contract="IMetadataExchange"/>
    </service>
    <endpointBehaviors>
        <behavior name="RestBehavior">
            <webHttp/>
        </behavior>
    </endpointBehaviors>
    

    Then there will be an endpoint at http://…/yourservice.svc/soap and another at http://…/yourservice.svc/rest

    [edit] to answer to your comment, what I said is to replace this section :

    <services>
      <service name="WebApi.SoapApi" behaviorConfiguration="ApiBehavior">
        <endpoint address="basic" bindingNamespace="http://api.myservice.dk/Basic" contract="WebApi.IApi" binding="basicHttpBinding" bindingConfiguration="ApiBinding" />
      </service>
      <service name="WebApi.JsonApi" behaviorConfiguration="ApiBehavior">
        <endpoint address="web" bindingNamespace="http://api.myservice.dk/Web" contract="WebApi.IApi" binding="webHttpBinding" bindingConfiguration="ApiBinding" behaviorConfiguration="JsonBehavior" />
      </service>
    </services>
    

    by :

    <services>
      <service name="WebApi.UniqueApi" behaviorConfiguration="ApiBehavior">
        <endpoint address="basic" bindingNamespace="http://api.myservice.dk/Basic" contract="WebApi.IApi" binding="basicHttpBinding" bindingConfiguration="ApiBinding" />
        <endpoint address="web" bindingNamespace="http://api.myservice.dk/Web" contract="WebApi.IApi" binding="webHttpBinding" bindingConfiguration="ApiBinding" behaviorConfiguration="JsonBehavior" />
      </service>
    </services>
    

    One service, with two endpoints

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

Sidebar

Related Questions

I have taken over an existing project written beautifully in SQL with many useful
I have taken over the development and maintenance of a production iOS application being
I have a good sized hobby project, around 66K LOC, over at http://www.wheelmud.net Recently,
I've recently taken over development of a website written in asp.net. Before taking this
After three years on a RESTful Java/ExtJS application, I have taken over development of
I have recently taken over development of a legacy system and want to be
I have taken over development of a website that integrates with Netsuite. The main
i have taken over a database that stores fitness information and we were having
I have taken over some code from a previous developer and have come across
I have taken three textboxes over aspx page. A JavaScript function is associated with

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.