1

構成されたエンドポイントを使用してIIS(IIS7、Windows 7)でWCFサービスをセットアップしようとしていますが、IIS構成で一般的であるように、それは傷ついた世界です。このサービスは、VS2010のデバッガーで正常に動作しますが、デプロイするときに、開くと次のメッセージが表示されますhttp://localhost:9000/MyApplication/_vti_bin/ListData.svc

[UriFormatException: Invalid URI: The hostname could not be parsed.]
  System.Runtime.AsyncResult.End(IAsyncResult result) +650220
  System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +210733
  System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +166

興味深いことに、更新するとメッセージが変わります。

[ArgumentException: An item with the same key has already been added.]
   System.Runtime.AsyncResult.End(IAsyncResult result) +650220
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +210733
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +166

2番目のエラーは最初のエラーの結果であると思いますので、最初にそれを追跡しようとしています。

今、私はあなたが何を考えているかを知っています:「この時点で長くて退屈なWeb.Configファイルを見るのは本当に素晴らしいことです。」あなたの願いは私の命令です:

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="loggingenabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="SecurityBehavior" name="MSMQSecuredService.SecuredMSMQService">
        <endpoint address="net.msmq://MyMachine/private/securedqueue"
          binding="netMsmqBinding" bindingConfiguration="SecuredBinding"
          name="EndpointMSMQ" contract="MSMQSecuredService.ISecuredMSMQService">
          <identity>
            <dns value="MyMachine" />
          </identity>
        </endpoint>
<!-- I have tried configuring the endpoint address to everything from the full path to this "/" with no change in outcome -->
        <endpoint address="/" binding="basicHttpBinding" name="EndPointHTTP"
          contract="MSMQSecuredService.ISecuredMSMQService" />
        <endpoint address="mex" binding="mexHttpBinding" name="EndPointIMEX"
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://MyMachine:9000/MyApplication" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SecurityBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True"/>
          <serviceCredentials>
            <serviceCertificate findValue="CertServer" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
            <clientCertificate>
              <certificate findValue="CertClient" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
              <authentication certificateValidationMode="None"/>
            </clientCertificate>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netMsmqBinding>

        <binding name="SecuredBinding" exactlyOnce="false" receiveErrorHandling="Fault">
          <security mode="Message">
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
      </netMsmqBinding>

    </bindings>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

明らかに、私は正確なマシン、アプリケーション、およびポート名を難読化するように努めてきたので、わずかな不一致があれば問題はないかもしれません。

IISで、net.msmqを含むようにサイトのバインディングを構成しました-問題についての私の最も良い推測は、「バインディング情報」が正しくないことです-現在のマシンのマシン名に設定すると、上記のメッセージが表示されます。これを「localhost」に設定すると、ASP.Netサーバーエラーが発生し、イベントログとWCFトレースファイルに次のように表示されます。

The service '/MyApplication/_vti_bin/ListData.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/MyApplication/_vti_bin/ListData.svc' does not exist.

おそらく、文句を言っているURIはバインディング情報のホスト名であると推測していますが、それが何である必要があるか、またはlocalhost正しい場合は、問題をさらに深く掘り下げる方法についての情報を見つけることができません。

追加するために編集:WCFトレースを有効にすると、次のパターンが発生します。

<Description>MsmqActivation service started scan for queues.</Description>
<AppDomain>/LM/W3SVC/2/ROOT/MyApplication-1-130053972428149879</AppDomain>

それで

<Description>Throwing an exception.</Description><AppDomain>/LM/W3SVC/2/ROOT/My-Application-1-130053972428149879</AppDomain>
<Exception>
  <ExceptionType>System.ServiceModel.EndpointNotFoundException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The service '/MyApplication/_vti_bin/ListData.svc' does not exist.</Message><StackTrace>   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
   at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.ServiceModel.EndpointNotFoundException: The service '/MyApplication/_vti_bin/ListData.svc' does not exist.</ExceptionString>
</Exception>

最後に、これを確認します。

<Description>MsmqActivation service cannot discover queues.</Description>
<AppDomain>/LM/W3SVC/2/ROOT/MyApplication-1-130053250352242318</AppDomain>
<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord">
  <Host>.</Host>
  <PublicQueues>True</PublicQueues>
</ExtendedData>
<Exception>
  <ExceptionType>System.Messaging.MessageQueueException, System.Messaging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</ExceptionType>
  <Message>A workgroup installation computer does not support the operation.</Message>
  <StackTrace>
  at System.Messaging.MessageQueue.GetMachineId(String machineName)
  at System.Messaging.MessageQueueCriteria.set_MachineName(String value)
  at System.Messaging.MessageQueue.GetPublicQueuesByMachine(String machineName)
  at System.ServiceModel.Channels.MsmqBindingMonitor.OnTimer(Object state)
  </StackTrace>
  <ExceptionString>System.Messaging.MessageQueueException (0x80004005): A workgroup installation computer does not support the operation.
     at System.Messaging.MessageQueue.GetMachineId(String machineName)
     at System.Messaging.MessageQueueCriteria.set_MachineName(String value)
     at System.Messaging.MessageQueue.GetPublicQueuesByMachine(String machineName)
     at System.ServiceModel.Channels.MsmqBindingMonitor.OnTimer(Object state)
  </ExceptionString>
</Exception>

さて、この最後の例外は最も示唆的であるように見えます-私が書き込もうとしているキューがであるときにシステムがパブリックキューを探しているように見えます./private$/MyApplication-それでそれを正しい方向に向けるために何を変更する必要がありますか?

4

2 に答える 2

2

私は同じ問題を抱えており、ここで解決策を見つけました - http://vijayvepak.blogspot.ru/2012/09/an-item-with-same-key-has-already-been.html webapp の Web サイト。右クリック -> バインドの編集 net.msmq プロトコルのバインド情報が localhost に設定されていることを確認します

このバグがあるすべてのワークステーションで役に立ちました。

于 2013-07-09T14:44:52.373 に答える