私はWCFサービスを公開するWindowsサービスを持っています。WCF Windowsサービスのアクセス許可を設定するにはどうすればよいですか?
また、WCFサービスと通信してコマンドを送信し、データを受信するアプリケーションもあります。
Visual Studioからアプリケーションを実行すると、これがうまく動作します。
ただし、アプリケーションをインストールして実行すると、アプリケーションはサービスと通信できません。 アプリケーションを実行するバッチファイルを停止してサービスを開始することもできません。
あなたは正しい方向に私を指すことができます私は「予備」URIするnetshを使用してみましたが、私は本当に私が
:-)やってるのか分からないのですか?
Windows ServerのコードWCFサービスコード(簡略):
private void InitializeConsoleComms()
{
try
{
//Prepare comms with the Console application
Type serviceType = typeof(InternetGauge_IO);
host = new ServiceHost(serviceType, new Uri[] { new Uri("http://localhost:8080/") });
// Add behavior for our MEX endpoint
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
host.Description.Behaviors.Add(behavior);
// Create basicHttpBinding endpoint at http://localhost:8080/RJB.InternetGauge/
host.AddServiceEndpoint(serviceType, new BasicHttpBinding(), "RJB.InternetGauge");
// Add MEX endpoint at http://localhost:8080/MEX/
host.AddServiceEndpoint(typeof(IMetadataExchange), new BasicHttpBinding(), "MEX");
host.Open();
logger.LogEvent("Console comms ready", "Internet Gauge", 4, 1);
}
catch (Exception e)
{
logger.LogEvent("Failed to open Console comms", "Internet Gauge", 1, 1);
logger.LogEvent("Exception : " + e.InnerException + " Stack Trace: " + e.StackTrace + " Message: " + e.Message, "RJB.InternetGauge.WindowsService.Main", 1, 1);
}
}
アプリケーションだけで、例えば生成されたプロキシとメソッドを使用しています:
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "WCF_Service" in both code and config file together.
[ServiceContract]
public class InternetGauge_IO
{
[OperationContract]
public void Pause()
{
RunningState.paused = true;
}
[OperationContract]
public void Continue()
{
RunningState.paused = false;
}
[OperationContract]
public bool GetRunningState()
{
return RunningState.paused;
}
....
Windows ServerのコードWCFエンドポイントのコードを作成します。
private bool GetRunningState()
{
try
{
InternetGauge_IOClient client = new InternetGauge_IOClient();
isRunning = true;
return(client.GetRunningState());
}
catch (Exception)
{
trayIcon.Text = "Internet Gauge Windows Service does not appear to be running.";
trayIcon.Icon = RJB.InternetGauge.Console.Properties.Resources.ServiceStopped;
isPaused = true;
isRunning = false;
return isPaused;
}
}
netshコマンドは、私は
netsh http add urlacl url=http://+:8080/InternetGauge_IO user=PC-01\richard
任意のアイデアを試してみましたか?
おかげ リチャード
どのようなエラーが表示されますか? –
また、http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-postsを参照してください –
InitializeConsoleCommsはいつ呼び出されますか?これは、サービスの起動時に呼び出される必要があります(OnStart())。 Visual StudioがWindowsサービスの代わりにWCFサービスをホストしているため、デバッグで動作する理由が考えられますか? –