Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Hosting Dynamics GP WCF service in IIS

Posted on by 3,732

Hi,

I am trying to host Dynamics GP WCF service in IIS. But I am facing two warning like this:

1) Argument 'debug' did not match any attributes

8547.image_2800_2_2900_.jpg

2) No attributes found to remove

7875.image_2800_3_2900_.jpg

This is my "Web.config" code:

<?xml version="1.0"?>

<configuration>

 <appSettings>

   <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>

 </appSettings>

 <system.web>

   <compilation targetFramework="4.0"/>

   <httpRuntime targetFramework="4.0"/>

 </system.web>

 <system.serviceModel>

   <bindings>

     <wsHttpBinding>

       <binding name="GPWebService"/>

     </wsHttpBinding>

     <webHttpBinding>

       <binding contentTypeMapper="JsonContentTypeMapper.Mapping, JsonContentTypeMapper, version=1.0.0.0, Culture=neutral,publicKeyToken=null"/>

     </webHttpBinding>

   </bindings>

   <client>

     <endpoint address="http://WIN-CMP7MKTCB96:48620/Dynamics/GPService/GPService" binding="wsHttpBinding" bindingConfiguration="GPWebService" contract="DynamicsGPService.DynamicsGP" name="GPWebService">

       <identity>

         <userPrincipalName value="GPSERVER\administrator"/>

       </identity>

     </endpoint>

   </client>

   <services>

     <service name="SalesOrderWCFService.SalesOrderProcessor" behaviorConfiguration="serviceBehavior">

       <endpoint address="rest" binding="webHttpBinding" behaviorConfiguration="restBehavior" contract="SalesOrderWCFService.ISalesOrderProcessor">

         <identity>

           <dns value="localhost"/>

         </identity>

       </endpoint>

       <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>

     </service>

   </services>

   <behaviors>

     <endpointBehaviors>

       <behavior name="restBehavior">

         <webHttp/>

       </behavior>

     </endpointBehaviors>

     <serviceBehaviors>

       <behavior name="serviceBehavior">

         <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>

         <serviceDebug includeExceptionDetailInFaults="false"/>

       </behavior>

       <behavior name="">

         <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>

         <serviceDebug includeExceptionDetailInFaults="false"/>

       </behavior>

     </serviceBehaviors>

   </behaviors>

   <protocolMapping>

     <add binding="basicHttpsBinding" scheme="https"/>

   </protocolMapping>

   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

 </system.serviceModel>

 <system.webServer>

   <modules runAllManagedModulesForAllRequests="true"/>

   <!--

       To browse web app root directory during debugging, set the value below to true.

       Set to false before deployment to avoid disclosing web app folder information.

     -->

   <directoryBrowse enabled="true"/>

 </system.webServer>

</configuration>

This is my "ISalesOrderProcessor.cs" code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.ServiceModel.Web;

using System.Text;

using System.IO;

namespace SalesOrderWCFService

{

   // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "ISalesOrderProcessor" in both code and config file together.

   [ServiceContract]

   public interface ISalesOrderProcessor

   {

           [OperationContract]

           [WebInvoke(Method = "POST", UriTemplate = "CreateSalesOrder", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]

           //  void salesOrder();

           [return: MessageParameter(Name = "response")]

           string sales(Stream stream);

    }

       // Use a data contract as illustrated in the sample below to add composite types to service operations.

       /*[DataContract]

       public class SalesOrderRequest

       {

           [DataMember(Name = "response")]

           public string Id { get; set; }

       }*/

       [DataContract]

       public class OrderRequest

       {

           string orderProcess;

           string customerId;

           string itemId;

           string batchKeyId;

           int quantity;

           [DataMember]

           public string OrderProcess

           {

               get { return orderProcess; }

               set { orderProcess = value; }

           }

           [DataMember]

           public string CustomerId

           {

               get { return customerId; }

               set { customerId = value; }

           }

           [DataMember]

           public string ItemId

           {

               get { return itemId; }

               set { itemId = value; }

           }

           [DataMember]

           public string BatchKeyId

           {

               get { return batchKeyId; }

               set { batchKeyId = value; }

           }

           [DataMember]

           public int Quantity

           {

               get { return quantity; }

               set { quantity = value; }

           }

       }

   }

This is my "SalesOrderProcessor.svc.cs" code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.ServiceModel.Web;

using System.Text;

using SalesOrderWCFService.DynamicsGPService;

using System.IO;

using System.Runtime.Serialization.Json;

namespace SalesOrderWCFService

{

   // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "SalesOrderProcessor" in code, svc and config file together.

   // NOTE: In order to launch WCF Test Client for testing this service, please select SalesOrderProcessor.svc or SalesOrderProcessor.svc.cs at the Solution Explorer and start debugging.

   public class SalesOrderProcessor : ISalesOrderProcessor

   {

      CompanyKey companyKey;

           Context context;

          // SalesOrder salesOrder;

           SalesDocumentTypeKey salesOrderType;

           CustomerKey customerKey;

           BatchKey batchKey;

           SalesOrderLine salesOrderLine;

           ItemKey orderedItem;

           Quantity orderedAmount;

           Policy salesOrderCreatePolicy;

           DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

           public string sales(Stream stream)

           {

               StreamReader reader = new StreamReader(stream);

               string reqJson = reader.ReadToEnd();

               DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(OrderRequest));

               MemoryStream mstream = new MemoryStream(Encoding.UTF8.GetBytes(reqJson));

               OrderRequest obj = (OrderRequest)ser.ReadObject(mstream);

               context = new Context();

               companyKey = new CompanyKey();

               companyKey.Id = (-1);

               context.OrganizationKey = (OrganizationKey)companyKey;

               DynamicsGPService.SalesOrder salesOrder = new DynamicsGPService.SalesOrder();

               salesOrderType = new SalesDocumentTypeKey();

               salesOrderType.Type = SalesDocumentType.Order;

               salesOrder.DocumentTypeKey = salesOrderType;

               customerKey = new CustomerKey();

               customerKey.Id = obj.CustomerId;

               salesOrder.CustomerKey = customerKey;

               batchKey = new BatchKey();

               batchKey.Id = obj.BatchKeyId;

               salesOrder.BatchKey = batchKey;

               salesOrderLine = new SalesOrderLine();

               orderedItem = new ItemKey();

               orderedItem.Id = obj.ItemId;

               salesOrderLine.ItemKey = orderedItem;

               orderedAmount = new Quantity();

               orderedAmount.Value = obj.Quantity;

               salesOrderLine.Quantity = orderedAmount;

               SalesOrderLine[] orders = { salesOrderLine };

               salesOrder.Lines = orders;

               salesOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesOrder", context);

               try

               {

                   wsDynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);

                   return "order created123";

               }

               catch (Exception ex)

               {

                   return string.Format("Exception:{0}",ex.Message);

               }

               finally

               {

                   if (wsDynamicsGP.State != System.ServiceModel.CommunicationState.Faulted)

               {

                   wsDynamicsGP.Close();

               }

               }

           }

        }

   }

I had created the new site in the IIS:

8666.image_2800_4_2900_.jpg

I am posting some data through Poster(Mozilla):

I read some blog, in that I think they installed WEB CLIENT in GP. So I started to install web client in GP. But I couldn't see the site which is available in IIS.

Can you tell me what I am missing. And tell me how IIS will talk through Dynamics GP 2013 R2.

*This post is locked for comments

  • Rajamohammed Profile Picture
    Rajamohammed 10 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Hi Sathish,

    Hope you are well, Can I get  a code for this? for reference.

  • Verified answer
    Sathish Sivakumar Profile Picture
    Sathish Sivakumar 3,732 on at
    RE: Hosting Dynamics GP WCF service in IIS

    HOSTING DYNAMICS GP WCF SERVICES IN IIS

    Step 1:

    Create a WCF service in Visual studio 2012

    Step 2:

    drive.google.com/.../edit

    (Here is the code link for reference)

    Step 3:

    Create new “Site” in IIS

    Step 4:

    Create a valid certificate in IIS

    Step 5:

    Start to install “WEBCLIENT” in Dynamics GP.

    Note: Give the site name and the certificate name where it ask.

    Step 6:

    Once the web client installation is finished you can see the two extra options in the IIS.

    1) DynGpWebApp

    2) DynGPWebMgmt

    We have to click “DynGPWebApp”.

    Step 7:

    In the Visual studio click the project and right click

    Give the service URL.

    Note: Enter the correct port Id(IIS which you create)

    Click “Publish”

    Note: Check the port Id is mentioned correctly in all the places.

    Step 8:

  • Suggested answer
    soma Profile Picture
    soma 24,406 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Sathish,

    Shall we know the purpose of hosting web services in IIS?

    I think, you have try to create sales orders with using web services. If am I correct, you no need to create a site in IIS. You just install and verify the web services with help of above mention document and create the sales order through visual studio code(msdn.microsoft.com/.../cc508441.aspx).

    Hope this helps!!!

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Hosting Dynamics GP WCF service in IIS

    Hi Satish,

    Please find the attached sample Sales Order code that may guide you with some resolution

    msdn.microsoft.com/.../cc508441.aspx

  • Sathish Sivakumar Profile Picture
    Sathish Sivakumar 3,732 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Hi Soma,

    Nice to your response. I am facing problem while hosting GP WCF service in IIS. I don't know how IIS will speak to GP? In this post I had mentioned all my problem, kindly please read that. Please help me. I don't have any idea about that.

  • Suggested answer
    soma Profile Picture
    soma 24,406 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Hi Sathish,

    Web Client is not recommended for GP web service(WCF). If you have installed the web services, please follow below link to verify your web service install.

    www.azurecurve.co.uk/.../verifying-the-install-of-web-services-for-microsoft-dynamics-gp-2013

    If you want to install web service, go to your GP media and find the installer under the AdProd folder then download the installation and admin guide for web services from below link to install the same.

    www.microsoft.com/.../details.aspx

    Note: Web client is only used for Hosting GP to web application(Accessing GP through browser).

    Hope this helps!!!

  • Sathish Sivakumar Profile Picture
    Sathish Sivakumar 3,732 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Is "Web Client" installation is mandatory for hosting dynamics GP WCF service in IIS?

  • Suggested answer
    rudra Profile Picture
    rudra 6,534 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Also refer the below link how to create a ssl cert in clear cut

    www.dotnetcurry.com/showarticle.aspx

  • Suggested answer
    rudra Profile Picture
    rudra 6,534 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Select a certificate to configure the service for SSL access(optional) this option is for marking up the SSL certificate, once you create the ssl certificate in the IIS then you will get the ssl certificate in your dropdown. 

    From the above link "GP Web Client" is the name of the SSL certificate created in the IIS.

    Please refer the link to create:-

    technet.microsoft.com/.../cc753127(v=ws.10).aspx

  • Sathish Sivakumar Profile Picture
    Sathish Sivakumar 3,732 on at
    RE: Hosting Dynamics GP WCF service in IIS

    Hi Rudra,

    I couldn't see the "GP Web Client" option on "Select a certificate to configure the service for SSL access(optional)".

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans