WCF - 无法在IIS WAS下为NetMsmq绑定生成元数据/实现MEX?

时间:2011-11-15 21:32:49

标签: wcf

我在WAS下成功实现了NetTcp绑定和元数据,但我遇到了WAS / IIS下的netMsmqBinding问题。简而言之,我可以为自托管NetMsmq绑定应用程序实现MEX,但不能为WAS / IIS实现。似乎WAS拒绝我使用的任何地址,我可以使用自托管应用程序中的任何地址。换句话说,我可以在自托管中执行此操作:

<system.serviceModel>
    <services>
      <service name="Microsoft.Samples.MSMQTransactedSample.OrderProcessorService" behaviorConfiguration="OrderProcessorServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/ServiceModelSamples/service" />
          </baseAddresses>
        </host>
        <!-- Define NetMsmqEndpoint -->
        <endpoint address="net.msmq://localhost/private/ServiceModelSamplesTransacted" binding="netMsmqBinding" bindingConfiguration="TransactedBinding" contract="Microsoft.Samples.MSMQTransactedSample.IOrderProcessor" />
        <!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="OrderProcessorServiceBehavior">
          <serviceMetadata httpGetEnabled="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netMsmqBinding>
        <binding name="TransactedBinding">
          <security mode="None" />
        </binding>
      </netMsmqBinding>
    </bindings>
  </system.serviceModel>

然而,当我在WAS中尝试类似的东西时,它表示在地址8000处没有端点升级。它不会托管metdata。有人可以帮我在WAS中获取元数据或为NetMsmq实施MEX:

<system.serviceModel>
    <bindings>
      <netMsmqBinding>
        <binding name="MsmqBindingNonTransactionalNoSecurity" exactlyOnce="false">
          <security mode="None"/>
        </binding>
      </netMsmqBinding>
    </bindings>
  <services>  
      <service name="Portal.LoadSim.Services.MsmqService" behaviorConfiguration="PortalServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/PortalLoadSimServices10/MsmqService"/>
          </baseAddresses>
        </host>
        <!-- Define NetMsmqEndpoint -->
        <endpoint address="net.msmq://localhost/private/PortalLoadSimServices10/MsmqService.svc" binding="netMsmqBinding" bindingConfiguration="MsmqBindingNonTransactionalNoSecurity" contract="Portal.LoadSim.Shared.IMsmqService" />
        <!-- the mex endpoint is exposed at http://localhost:8000/PortalLoadSimServices10/MsmqService/mex -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

      </service>

    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="PortalServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

1 个答案:

答案 0 :(得分:0)

您需要为服务添加URL访问控制。此命令应该适合您:

netsh http add urlacl url=http://localhost:8000/PortalLoadSimServices10/MsmqService user="NT AUTHORITY\NetworkService" listen=yes

删除条目

delete urlacl url=http://localhost:8000/PortalLoadSimServices10/MsmqService

HTH

更新:这不是您问题的答案。如果您希望将服务作为自托管应用程序运行并在非标准帐户下运行,则可以执行此操作。对不起,我搞砸了。我尝试在家中的示例应用程序上使用您的配置,发现我必须做两件事才能让它工作 - 一,我必须将队列重命名为svc文件的路径和名称(例如PortalLoadSimServices10 / MsmqService.svc)而不是使用基地址只是浏览到IIS主机应用程序中的svc文件。您可能还需要修改队列权限,以便iis可以正确访问它。如果这解决了您的问题,请告诉我。