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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:17:18+00:00 2026-05-30T22:17:18+00:00

I created a simple wcf service that retrieves data from crm 4.0 using the

  • 0

I created a simple wcf service that retrieves data from crm 4.0 using the advanced developer tools. I queried the data successfully using linq. The classes were generated using crmsvcutil. However, when I converted this to a wcf service as below it keeps crashing.

namespace CRMDataRetrieval
 {    
 [ServiceContract]
public interface ICRMData
{
    [OperationContract]
    string getValue();

}

public class CRMDataService : ICRMData
{
    public string getValue()
    {
        DataContext context = new DataContext("entities");  //entities is name of    classes that were generated by crmsvcutil

        string name = null;
        var query = from n in context.contacts
                    where n.acctNum == "01218515"
                    select n.nickname;
        foreach (var result in query)
            name = result;
        return name;
    }

In the WCF Service Host, the service is stopped but it also shows Entities.CmsDataService as being stopped as well. When i click on this, the additional Information says that The service(Entities.CmsDataService) cannot be started. This service has no endpoint defined. Please add at least one endpoint for the service in config file and try again.

As things stand my app.config looks like below. So how and where would I add the endpoints in the config file for the autogenerated classes so that they work nicely with WCF? or would I need to make any other changes? Please be detailed in your explanation. As usual, thanking you in advance.

    <?xml version="1.0"?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <add name="entities" connectionString="Authentication Type=ad; Server=http://****; User ID=*\*******; Password=*******"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings />
    <client />
    <services>
      <service name="CRMDataRetrieval.CRMDataService">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:7432/account"/>
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint name="wsHttpBinding_ICRMData" address="ws" binding="wsHttpBinding" contract="CRMDataRetrieval.ICRMData"/>


        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>

      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
  • 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-30T22:17:20+00:00Added an answer on May 30, 2026 at 10:17 pm

    Look at crmsvcutil parameters. There are /dataContextPrefix and /dataContextClassName. Use these parameters to set proper name for generated data context. Use the generated context as it described here

    CrmConnection crmc = CrmConnection.Parse("Authentication Type=Passport; Server=https://" + org + ".crm.dynamics.com/" + org + "; User ID=myuser; Password=mypassword; Device ID=mydeviceid; Device Password=mydevicepassword");
    var yourDataContext = new GeneratedDataContext(crmc);
    

    Unfortunately I don’t have CRM 4.0 installed. But I can provide code for CRM 2011:

    namespace CRMDataRetrieval
    {
        public class CRMDataService : ICRMData
        {
            public string getValue()
            {
                var connection = CrmConnection.Parse("Url=https://orgname.crm.dynamics.com; Username=OpenId; Password=; DeviceID=####; DevicePassword=####");
                var service = new OrganizationService(connection);
                MyServiceContext context = new MyServiceContext(service);
    
                string name = null;
                var query = from n in context.ContactSet
                            where n.ContactId == new Guid("00000000-0000-0000-0000-000000000000")
                            select n.FullName;
                foreach (var result in query)
                    name = result;
    
                return name;
            }
        }
    }
    

    I used endpoint configuration you provided.

    To generate classes I used

    crmsvcutil.exe /url:https://orgname.crm.dynamics.com/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /n:MyCrmNamespace /u:"OpenId" /p:"####" /serviceContextName:MyServiceContext /di:#### /dp:####
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an Ajax enabled WCF web service that contains this simple method:
I am writing a web service using WCF. I created data contracts. I created
Created a simple WCF service that basically logs to a db. the build is
I created a simple wcf service that exposes a GetData method. It's actually the
I created a simple WCF web service that has one method: SubmitTicket(flightticket ft, string
I have created a simple WCF service that is to be configured by an
I have created a simple WCF service by following a MSDN tutorial. I successfully
I have created a simple wcf service which used the WCF Service Library template.
I have a WCF service that uses the entity framework to retrieve records from
I created a simple RESTful WCF service with a single method for receiving files

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.