none
HIS 2013 ClientContext is not working for WCF Service RRS feed

  • Question

  • Hello,

    In my project I need to select the RemoteEnvironment.

    First I'm trying to follow the WcfService solution provided by Microsoft Host Integration Server 2013 SDK v1.0, but doesn't work the ClientContext class when I want to change the RemoteEnvironment. These lines are added to the program.cs class, but does not work, the result is the same in both cases, just take the remoteEnvironment Name that isDefault = "true" in app.config file:

    ClientContext clientContext = new ClientContext();

    clientContext.RemoteEnvironment = "ELM Link RE 1";

    accountBalance = proxy.GetBalance("Kim Akers", "123456");

    clientContext.RemoteEnvironment = "ELM Link RE 2 ";

    accountBalance = proxy.GetBalance("Kim Akers", "123456");

    I would appreciate any help,

    Regards,

    Belen


    Belen

    Tuesday, October 20, 2015 3:30 PM

Answers

  • Hello,

    The simplest way to use WCF is to host the object in IIS (Internet Information Services).

    When you create a new TI Object in Visual Studio and you save it, it will create a complete directory structure with web.config, .asmx (webservice), .svc (wcf), and the Bin folder containing the TI Object Assembly. You only have to create a virtual directory in IIS, put the .svc and the web.config in the root and the TI Assembly in the Bin Folder. 

    Now in you .Net Application, you have to add a service reference to that IIS Virtual Directory WCF Service.

    Have you tried to recreate a new TI Object ?

    I cannot see your screenshot :-(

    You should use Webservice or WCF Restriction in order to make it work.

    Best regards,


    Steve Melan - BCEE My Blog : http://stevemelan.wordpress.com

    Thursday, October 29, 2015 6:36 PM

All replies

  • Hello Belen,

    In order to use the client context together with WCF or Webservice, you have to create the TI Object with client context, this is a flag on the instance level. After that you should be able to call the TI Object with the client context (RemoveEnvironment).

    The code should be similar afterwards to :

    Proxy.Service proxy = new Proxy.Service();

    Proxy.ClientContext ct = new Proxy.ClientContext();

    ct.RemoteEnvironment = "ELM Link RE 1";

    accountBalance = proxy.GetBalance("Kim Akers", "123456", ct);

    In order to change the TI Object, just open it in Visual Studio (Host Integration Server needs to be installed on that computer).

    Hope this helps :-)

    Best regards,


    Steve Melan - BCEE My Blog : http://stevemelan.wordpress.com

    Wednesday, October 28, 2015 1:07 PM
  • Hello Steve,

    I've changed the TI object so that the GetBalance Method has the Context Type = ClientContext,  as you can see in the image bellow

    After compile and publish the service project again, I have not the option to add this argument in the method GetBalance
    Error 5 No overload for method 'GetBalance' Takes 3 arguments

     

    If the TI object is saved with the property Calling mode = WCF, the interface don't  have the  ref to ClientContext.

    But if I save it as "Direcc call" or "Web service", then I have this reference:

    #region CustomTI properties
          [CustomTI("07257F45-FB76-11CF-B949-00A0C9034817", 1)]
    #endregion
          ref  Microsoft.HostIntegration.TI.ClientContext clientContext

    I do not know if I'm doing something wrong, I appreciate any help or suggestions
    Thank you.



    Belen

    Wednesday, October 28, 2015 4:05 PM
  • Hello,

    The simplest way to use WCF is to host the object in IIS (Internet Information Services).

    When you create a new TI Object in Visual Studio and you save it, it will create a complete directory structure with web.config, .asmx (webservice), .svc (wcf), and the Bin folder containing the TI Object Assembly. You only have to create a virtual directory in IIS, put the .svc and the web.config in the root and the TI Assembly in the Bin Folder. 

    Now in you .Net Application, you have to add a service reference to that IIS Virtual Directory WCF Service.

    Have you tried to recreate a new TI Object ?

    I cannot see your screenshot :-(

    You should use Webservice or WCF Restriction in order to make it work.

    Best regards,


    Steve Melan - BCEE My Blog : http://stevemelan.wordpress.com

    Thursday, October 29, 2015 6:36 PM