FrameworkServiceClient Error

Plugins skapade av Switch Kings användare | Plugins created by Switch King users
Post Reply
Behner
1 star
1 star
Posts: 8
Joined: Sat 08 Dec 2012, 23:18

FrameworkServiceClient Error

Post by Behner » Sun 18 May 2014, 20:33

Im trying to work against http://ip:8080/SwitchKingFrameworkServiceHost in the IMonitoredEventInterceptor Interface.
I have added a service Reference and are working against it like this:

Code: Select all

try
{
    SwitchKingServer.FrameworkServiceClient t = new SwitchKingServer.FrameworkServiceClient();                
}
catch (Exception e)
{
      System.IO.File.AppendAllText(@"c:\data\YouDidIt.txt", "Error: " + e.Message + Environment.NewLine);
}
When the code runs within the plugn i get this error from the exception:

Code: Select all

Could not find default endpoint element that references contract 'SwitchKingServer.FrameworkService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
When I create a console Application and run the same code from the commandline I get no error and the communication against FrameworkServiceClient Works nicely.

Anyone got an idea?
Last edited by Behner on Sun 18 May 2014, 21:50, edited 3 times in total.

Isaksson
5 stars
5 stars
Posts: 637
Joined: Tue 09 Nov 2010, 21:51
Location: Västervik

Re: Error in plugin IMonitoredEventInterceptor

Post by Isaksson » Sun 18 May 2014, 21:08

Have you tried to add

Code: Select all

return false;
after your code block in that interface, so that it always returns a value.

Behner
1 star
1 star
Posts: 8
Joined: Sat 08 Dec 2012, 23:18

Re: Error in plugin IMonitoredEventInterceptor

Post by Behner » Sun 18 May 2014, 21:15

Thx, I actually solved that problem like that. It seems like it anyway.

I was maybe a bit fast posting my trouble, but now I still have this issue With FrameworkServiceClient.
I changed the content on my post to reflect this. Sorry @Isaksson :)

Behner
1 star
1 star
Posts: 8
Joined: Sat 08 Dec 2012, 23:18

Re: FrameworkServiceClient Error

Post by Behner » Mon 19 May 2014, 18:54

I solved this With using the REST service insted like this:

Code: Select all


        private static void SetScenario(int setScenarioID)
        {
            WebRequest req = WebRequest.Create(@"http://ip:8800/commandqueue?operation=changescenario&target=" + setScenarioID.ToString() + "&param1=¶m2=¶m3=");

            System.Net.CredentialCache credentialCache = AuthenticateUser();

            req.Credentials = credentialCache;
            req.Method = "GET";

            HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
            if (resp.StatusCode == HttpStatusCode.OK)
            {
                System.IO.File.AppendAllText(@"c:\data\YouDidIt.txt", "Success" + Environment.NewLine);
            }
            else
            {
                System.IO.File.AppendAllText(@"c:\data\YouDidIt.txt", "Error in REST " + Environment.NewLine);
            }
        }

        private static CredentialCache AuthenticateUser()
        {
            System.Net.CredentialCache credentialCache = new System.Net.CredentialCache();
            credentialCache.Add(
                new System.Uri("http://ip:8800"),
                "Basic",
                new System.Net.NetworkCredential("user", "password")
            );
            return credentialCache;
        }

The code sets a spesific scenario.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests