標準の名前付きパイプエンドポイントを通じてAppFabricでホストされているワークフローサービスを管理しようとしています。私は正常にコンソールアプリケーションからこれを行うことができますが、ASP.NETから同じことをしようとすると "アクセスが拒否されました"という例外が発生します。net.pipeバインディングを使用してASP.NETからワークフローサービスを管理する方法
NetNamedPipeBinding binding = new NetNamedPipeBinding();
EndpointAddress addr = new EndpointAddress("net.pipe://localhost/ServiceLibrary/LongRunningService.xamlx/System.ServiceModel.Activities_IWorkflowInstanceManagement");
try
{
var proxy = new WorkflowControlClient(binding, addr);
Guid instanceId = new Guid("<<SOME WORKFLOW INSTANCE ID>>");
proxy.Suspend(instanceId);
}
catch (Exception ex)
{
}
:
私はそれがweb.configファイルに何らかの形で解決すべきセキュリティの設定の問題だということを理解するが、私はどのように考えている...ここで
は、私が使用するコードです。更新: 理論上、web.configでエンドポイント(httpまたはnet.pipeのいずれか)をセキュリティなしで登録することは可能です。この場合、すべてが機能しているように見えますが、サイトに登録されているすべてのサービスに対してこれを実行したくありません。私はすでに登録されているnet.pipeエンドポイントに接続する方法があるはずだと思います。ここで(HTTP、net.pipe)明示的なエンドポイントの登録とWeb構成である:<behaviors>
<serviceBehaviors>
<behavior>
<remove name="serviceCredentials" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<sqlWorkflowInstanceStore instanceCompletionAction="DeleteNothing" instanceEncodingOption="None" instanceLockedExceptionAction="NoRetry" connectionStringName="ApplicationServerWorkflowInstanceStoreConnectionString" hostLockRenewalPeriod="00:00:30" runnableInstancesDetectionPeriod="00:00:05" />
<workflowInstanceManagement authorizedWindowsGroup="" />
<workflowUnhandledException action="AbandonAndSuspend" />
<workflowIdle timeToPersist="00:00:30" timeToUnload="00:01:00" />
<etwTracking profileName="Troubleshooting Tracking Profile" />
</behavior>
<behavior name="StnandardBehavior">
<remove name="serviceCredentials" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<sqlWorkflowInstanceStore instanceCompletionAction="DeleteNothing" instanceEncodingOption="None" instanceLockedExceptionAction="NoRetry" connectionStringName="ApplicationServerWorkflowInstanceStoreConnectionString" hostLockRenewalPeriod="00:00:30" runnableInstancesDetectionPeriod="00:00:05" />
<workflowInstanceManagement authorizedWindowsGroup="" />
<workflowUnhandledException action="AbandonAndSuspend" />
<workflowIdle timeToPersist="00:00:30" timeToUnload="00:01:00" />
<etwTracking profileName="Troubleshooting Tracking Profile" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="httpSecurityOff" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<netNamedPipeBinding>
<binding name="pipeSecurityOff" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport protectionLevel="None" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<services>
<service name="LongRunningService" behaviorConfiguration="StnandardBehavior">
<endpoint address="wce" contract="System.ServiceModel.Activities.IWorkflowInstanceManagement" binding="basicHttpBinding" bindingConfiguration="httpSecurityOff" kind="workflowControlEndpoint" />
<endpoint address="wce" contract="System.ServiceModel.Activities.IWorkflowInstanceManagement" binding="netNamedPipeBinding" bindingConfiguration="pipeSecurityOff" kind="workflowControlEndpoint" />
<endpoint contract="ILongRunningService" binding="basicHttpBinding" bindingConfiguration="httpSecurityOff" />
</service>
</services>
この場合には、この新しいエンドポイントに接続するためのクライアントコードは、少しは他のことのようになります。
NetNamedPipeBinding binding = new NetNamedPipeBinding();
binding.Security.Mode = NetNamedPipeSecurityMode.None;
EndpointAddress addr = new EndpointAddress("net.pipe://{{MACHINE_NAME}}/ServiceLibrary/LongRunningService.xamlx/wce");
try
{
var proxy = new WorkflowControlClient(binding, addr);
Guid instanceId = new Guid(workflowInstanceId.Value);
proxy.Suspend(instanceId);
proxy.Close();
}
catch (Exception ex)
{
}
はい、追加しました。私はこのコードが私のコンソールアプリケーションから動作すると言ったので... –
[WAS](http://msdn.microsoft.com/en-us/library/ms734677.aspx)を有効にしましたか? [関連するSO post](http://stackoverflow.com/a/1707612/175679)を参照してください。 – SliverNinja
IIS上のAppFabricでサービスがホストされている場合、この問題にどのように関連しましたか? –