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

  • Home
  • SEARCH
  • 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 9084913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:07:05+00:00 2026-06-16T21:07:05+00:00

I have a WCF service with 2 endpoints (1 webHttpBinding and 1 basicHttpBinding) that

  • 0

I have a WCF service with 2 endpoints (1 webHttpBinding and 1 basicHttpBinding) that is hosted in IIS. Clients are able to make http requests without a problem. I was able to connect and make calls to the SOAP endpoint via the WCFTestClient, and was able to successfully add the service reference to my client project. The problem is that there is no code generated in the Reference.cs file or the app.config file on the client…they’re both empty.

My question is, why would I be able to connect and make calls to the SOAP endpoint without a problem through the WCFTestClient but not through the Add Service Reference method?

EDIT: It seems to be an issue with the references I have on the assembly I’m adding the service reference to. I’m referencing another class library (the same library exists on the service) and am getting this warning when I build my solution:

Warning 12  Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Referenced type 'MyNamespace.KPI.ChartObject`2, MyNamespace.KPI.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e720b7e8a51f8d5' with data contract name 'ChartObjectOfdecimalZKPIPeriodaU4eboDJ' in namespace 'http://schemas.datacontract.org/2004/07/MyNamespace.KPI' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types.

It should be noted that this specific class is a generic class…I don’t know if this has anything to do with the error.

  • 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-06-16T21:07:06+00:00Added an answer on June 16, 2026 at 9:07 pm

    You need to follow your ABC’s:

    • Address
    • Binding
    • Contract

    An address that is exposed through HTTP just needs a deployment URL. Which the Internet Information System is handling all of that for you. However; if you attempt to use the Service Reference without the proper definitions- it will not show. As it has no details of where it is going.

    Once you’ve defined that criteria it should appear per normal.


    Update:

    You can culminate SOAP and REST off the same Service Contract or you can separate them. In this example; I’ll separate them.

    Create the Service:

    [ServiceContract]
    public interface IMath
    {
          [OperationContract]
          int Add(int Number1, int Number2);
    }
    

    Create the Service Contract for Rest:

    [ServiceContract]
    public interface IMathRest
    {
    
         [OperationContract]
         [WebGet(UriTemplate = "/Add/{Number1}/{Number2}", RequestFormat = WebMessageFormat.Json,
                  ResponseFormat = WebMessageFormat.Json)]
         int AddRest(string Number1, string Number2);
    }
    

    In the above service; it is explicitly setting the message format.

    Implement the Service: “Binding”

    public class Math : IMath, IMathRest
    {
         public int Add(int Number1, int Number2)
         {
             return Number1 + Number2;
         }
    
         public int AddRest(string Number1, string Number2)
         {
             int num1 = Convert.ToInt32(Number1);
             int num2 = Convert.ToInt32(Number2);
             return num1 + num2;
         }
    }
    

    Configure the Service:

    <serviceBehaviors>
          <behavior name = "servicebehavior">
              <serviceMetadata httpGetEnabled = "true" />
              <serviceDebug includeExceptionDetailInFaults = "false" />
          </behavior>
    </serviceBehaviors>
    

    The above will set the service to Basic / Web Http.

    After you’ve configured your serviceBehavior you’ll need to define the endpoint:

    <endpointBehaviors>
         <behavior name="restBehavior">
              <webHttp/>
         </behavior>
    </endpointBehaviors>
    

    This will configure your Rest Endpoint to the webHttpBinding specified above. Now you need to define your Soap.

    <endpoint name = "SoapEndPoint"
           contract = "Namespace in which Service Resides goes here"
           binding = "basicHttpBinding" <!-- Mirrors are above configuration -->
           address = "soap" />
    

    The above will go into your configuration; however at the time of consumption of the service- the endpoint name is required. The endpoints will be available at the Base Address / Soap Address. The binding used is specified.

    Except we have only configured our Soap, not our Rest. So we need to specify our endpoint:

    <endpoint name = "RestEndPoint"
           contract = "Namespace that our Rest Interface is located goes here"
           binding = "webHttpBinding"
           address = "rest"
           behaviorCOnfiguration = "restBehavior" />
    

    Our Rest Endpoint will be called at our Url (Base Address / Rest/ Add / Parameter / Parameter). We’ve specified our binds; and set our Rest Behavior.

    When you put the whole thing together; it would look like:

    <?xml version="1.0"?>
    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name ="servicebehavior">        
              <serviceMetadata httpGetEnabled="true"/>        
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="restbehavior">
              <webHttp/>
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <services>
          <service name ="MultipleBindingWCF.Service1"
                   behaviorConfiguration ="servicebehavior" >
            <endpoint name ="SOAPEndPoint"
                      contract ="MultipleBindingWCF.IService1"
                      binding ="basicHttpBinding"
                      address ="soap" />
    
            <endpoint name ="RESTEndPoint"
                      contract ="MultipleBindingWCF.IService2"
                      binding ="webHttpBinding"
                      address ="rest"
                      behaviorConfiguration ="restbehavior"/>
    
            <endpoint contract="IMetadataExchange"
                      binding="mexHttpBinding"
                      address="mex" />
          </service>
        </services>   
      </system.serviceModel>
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer> 
    </configuration>
    

    Consuming:

    To consume our Soap it is simple; straight forward. Make the Service Reference and make the call.

    static void CallingSoapFunction()
    {
         SoapClient proxy = new SoapClient("SoapEndPoint");
         var result = proxy.Add(7,2); // Proxy opens the channel, we invoke our method, we input our parameters.
         Console.WriteLine(result);
    }
    

    Except our Restful consumption is slightly different; especially since we have to Format it to Json. So we need to specify the name exactly.

    Rest is going to rely on Json for De-serialization of the data.

    static void CallRestFunc()
    {
         WebClient RestProxy = new WebClient();
         byte[] data = RestProxy.DownloadData(new Uri("http://localhost:30576/MathRest.svc/Rest/Add/7/2")); // As you see it is following the exact location of the project, invoking method / parameter and so on down the line.
    Stream stream = new MemoryStream(data);
    DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(string));
    string result = obj.ReadObject(stream).ToString();
    Console.WriteLine(result);
    }
    

    The above will download the data using the Rest Uri. Deserialize that data; and become displayed.

    Hopefully that helps clarify.

    If the proper items aren’t created in your configuration file; then it will not allow the proper consumption. The ABC’s are critical in WCF. If it isn’t created in the configuration file you’ll need to programatically create them in the code.


    Update:

    static void Main(string[] args)
    {
        var binding = new BasicHttpBinding();
        var endpoint = new EndpointAddress("http://localhost:8080/");
        using (var factory = new ChannelFactory<IPerson>(binding, endpoint))
        {
            var request = new Dictionary<Guid, Person>();
            request[Guid.NewGuid()] = new Person { Name = "Bob", Email = "Bob@abc.com" };
    
            var client = factory.CreateChannel();
            var result = client.SetCustomer(request);
    
            Console.WriteLine("Name: {0} | Email: {1}", result.Name, result.Email);
            factory.Close();
        }
        Console.ReadKey(true);
    }
    

    As you see in this basic example; the binding and endpoint are both configured. You need to ensure that all of these are defined in both your server and client. It has to know where it is going. Does that make more sense?

    • 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 that exposes two endpoints. One with a WebHttpBinding (acting
I have a WCF Service Using MSMQ hosted on IIS. I want to create
I have a WCF service with custom binding, hosted in IIS (IIS Express in
I have a .Net service running on IIS 6 and WCF that I want
I have create a WCF Service and hosted the Service in IIS (5.1). I
I have a wcf service that was accessible via http or https. It runs
I have a WCF RESTful web service (using the webHttpBinding) running under IIS, exposed
I have a WCF service that has REST and SOAP endpoints for every service.
I have a C# WCF service using a webHttpBinding endpoint that will receive and
I have a WCF service that is using webHttpBinding on an endpoint, and the

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.