Web services in the Microsoft dynamics CRM RRS feed

  • Question

  • Hi, I am very new to this Dynamics CRM. I want to upload web service file into the Microsoft dynamics instance. Is there any document related to this? If so please any one can share with me. I want in detail how to work with Dynamics CRM.

    Thank you,

    A.Pramod Kumar

    Friday, March 7, 2014 12:59 PM

All replies

  • Hi Pramod,

    Do you mean you want to invoke the Dynamics CRM web services and perform operations like creating, updating, retrieving, etc. data to and from CRM? If that is what you want, have a look here http://msdn.microsoft.com/en-us/library/gg309557.aspx

    <a href="http://mscrmhacks.com/admin-quikview-solution-crm-2013">Admin QuikView Solution for CRM 2013</a>

    Friday, March 7, 2014 2:40 PM
  • Hi,

    Please go through this document using web services

    please go through this if u have any doubt feel free to ask

    Before we get started, here’s the list of requirements

    • Microsoft Visual Studio 2010
    • MS .NET Framework 4.0
    • MS CRM SDK 2011

    Walkthrough Steps: Web Service

    • Open Visual Studio 2010
    • Select your project, ASP.NET Empty Web Application
    • Select a suitable name of your project
    • On Successful Creation of Project

    • Go to Solution Explorer
    • Add New Item: Web Service

    • Provide a suitable name
    • Click on Add to create
    • You will see the C# content in “CRMSERVICE.asmx”



    • Add reference to CRM Assemblies.
      • microsoft.crm.sdk.proxy
      • microsoft.xrm.client
      • microsoft.xrm.sdk



    •  Adding another .NET Assemblies.
      • System.Net
      • System.Security
      • System.Runtime.Serialization
      • System.ServiceModel
      • System.IdentityModel




    • Declare    CRM SDK Namespaces.
      • Microsoft.Xrm.Sdk;
      • Microsoft.Xrm.Sdk.Client;
      • Microsoft.Xrm.Sdk.Query;
      • Microsoft.Xrm.Sdk.Messages;



    • Web Service Code      

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

    using System.Web.Services;

    using System.ServiceModel.Description;

    using Microsoft.Xrm.Sdk;

    using Microsoft.Xrm.Sdk.Client;

    using Microsoft.Xrm.Sdk.Query;

    using Microsoft.Xrm.Sdk.Messages;




        /// <summary>

        /// Summary description for CRMSERVICE

        /// </summary>

        [WebService(Namespace = "http://tempuri.org/")]

        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]


        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

        // [System.Web.Script.Services.ScriptService]

        public class CRMSERVICE : System.Web.Services.WebService




            public string CreateQuote(string name, string billtoname, string state, string group, string city, string discountamount, string freightamount, string billtostreet1, )



                string message = string.Empty;



                    OrganizationServiceProxy serviceProxy;

                    ClientCredentials deviceCredentials = null;

                    ClientCredentials clientCredentials = null;

                    Guid id = Guid.Empty;


                    //Organization URL

                    Uri OrganizationUri = new Uri(String.Format("http://ur organization url/organizationname/XRMServices/2011/Organization.svc"));

                    //Discovery URL

                    Uri HomeRealmUri = new Uri(String.Format("http:// ur organization url/XRMServices/2011/Discovery.svs"));

                    //Setting Client Credentials

                    clientCredentials = this.GetCredentials("username", "Password");

                    //Get the Device Id and Password

                    //  deviceCredentials = this.GetDeviceCredentials();

                    //Using Organization Service Proxy to instantiate the CRM Web Service

                    using (serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, clientCredentials, deviceCredentials))


                        // This statement is required to enable early-bound type support.

                        serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                        IOrganizationService service = (IOrganizationService)serviceProxy;

                        //Define Entity Object


                        Entity amiquote = new Entity("quote");



                        Guid customerid = getaaccountid(group, ref service);

                        string customertype = string.Empty;

                        if (customerid == Guid.Empty)


                            customerid = getaaccountid(group, ref service);

                            customertype = "quote";




                            customertype = "account";



                        amiquote.Attributes["name"] = name;

                        amiquote.Attributes["billto_name"] = name;

                        amiquote.Attributes["billto_stateorprovince"] = state;

                        amiquote.Attributes["billto_line1"] = billtostreet1;






                        //salesinvoice.Attributes["donotsendmm"] = mlist;


                        amiquote.Attributes["customerid"] = new EntityReference(customertype, customerid);


                        decimal b = Convert.ToDecimal(discountamount);

                        amiquote.Attributes["freightamount"] = new Money(b);

                        decimal d = Convert.ToDecimal(freightamount);


                        amiquote.Attributes["discountamount"] = new Money(d);



                        id = service.Create(amiquote);



                        message = "quote Created with new Code Name:- " + id + " Guid is" + id.ToString();




                catch (Exception ex)


                    message = ex.Message;



                return message;



            private Guid getaaccountid(string accountname, ref IOrganizationService service)


                ConditionExpression condition1 = new ConditionExpression();

                condition1.AttributeName = "name";

                condition1.Operator = ConditionOperator.Equal;



                FilterExpression filter = new FilterExpression();



                QueryExpression query = new QueryExpression();

                query.EntityName = "account";

                query.ColumnSet = new ColumnSet(true);

                query.Criteria = filter;


                RetrieveMultipleRequest request = new RetrieveMultipleRequest();

                request.Query = query;


                RetrieveMultipleResponse response = (RetrieveMultipleResponse)service.Execute(request);


                Guid accountid = Guid.Empty;


                foreach (Entity entity in response.EntityCollection.Entities)


                    accountid = (Guid)entity["accountid"];




                return accountid;



            protected virtual ClientCredentials GetCredentials(string username, string password)


                ClientCredentials credentials = new ClientCredentials();

                credentials.UserName.UserName = username;

                credentials.UserName.Password = password;

                return credentials;







    Monday, March 10, 2014 11:05 AM