跨域的WCF通信

时间:2011-01-26 00:35:10

标签: wcf wcf-security workflow-foundation-4

我有一个工作流WCF服务(ServiceDMZ),它安装在跨越防火墙的服务器上。此服务在该服务器上的Windows帐户下运行。帐户名称:DMZDomain \ DMZUserName。

我有另一个在我的开发机器(ServiceDev)上运行的工作流WCF服务。这是在我的Windows帐户下运行的自托管服务:DevDomain \ DevUserName。

ServiceDev使用发送和接收活动中的wsHttpContextBinding和上下文关联与ServiceDMZ进行通信。 ServiceDMZ使用回调地址在完成任务时与ServiceDev进行通信。

我在ServiceDev的发送活动中收到此错误:

  

System.ServiceModel.Security.SecurityNegotiationException:调用者未经过服务身份验证。 ---> System.ServiceModel.FaultException:无法满足安全令牌请求,因为身份验证失败。在System.ServiceModel.Security.IssuanceTokenProviderBase`1.ThrowIfFault(消息消息,EndpointAddress目标)的System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(消息消息,EndpointAddress目标)处于System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(消息incomingMessage, SspiNegotiationTokenProviderState sspiState)---内部异常堆栈跟踪的结束---在System.Activities.Runtime.FaultCallbackWrapper.Invoke的System.ServiceModel.Activities.InternalSendMessage.OnSendFailure(NativeActivityFaultContext context,Exception propagatedException,ActivityInstance propagatedFrom)中(NativeActivityFaultContext faultContext,Exception) System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor,BookmarkManager bookmarkManager)中的propagatedException,ActivityInstance propagatedFrom)

ServiceDev和ServiceDMZ的app.config文件中的设置应该是什么?

谢谢!

您好,感谢您的评论。以下是配置文件。

ServiceDev

  <system.serviceModel>
<services>
  <service name="ServiceDev" behaviorConfiguration="ServiceDevBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://10.204.78.16:9101/"/>
      </baseAddresses>          
    </host>
    <endpoint address="http://10.204.78.16:9101/ServiceDev" binding="wsHttpBinding" contract="IServiceDev" bindingConfiguration="ServiceDevBinding"></endpoint>
    <endpoint address="http://10.204.78.16:9101/ServiceDev/mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
    <endpoint address="http://10.204.78.16:9101/ServiceDevCallback" binding="wsHttpContextBinding" contract="IServiceDevCallback" bindingConfiguration="ClientServiceDMZBinding"></endpoint>        
  </service>
</services>
<client>
  <endpoint address="http://10.169.24.14:9100/ServiceDMZ" binding="wsHttpContextBinding" contract="IServiceDMZ" name="ClientServiceDMZ" bindingConfiguration="ClientServiceDMZBinding">
    <identity>
      <userPrincipalName value="DMZUserName@dmzsvr1.mysite.com"/>
    </identity>
  </endpoint>
</client>
<bindings>
  <wsHttpBinding>
    <binding name="ServiceDevBinding" maxReceivedMessageSize="8388608">
      <security>
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="TripleDesRsa15" establishSecurityContext="true"/>
      </security>
    </binding>
  </wsHttpBinding>
  <wsHttpContextBinding>
    <binding name="ClientServiceDMZBinding" clientCallbackAddress="http://10.204.78.16:9101/ServiceDevCallback">
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security>
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
      </security>
    </binding>
  </wsHttpContextBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceDevBehavior">
      <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true"/>
      <serviceMetadata httpGetEnabled="true"/>
      <sqlWorkflowInstanceStore connectionStringName="MySite.Deployment.Data.Providers.WorkflowInstanceStoreProvider" instanceCompletionAction="DeleteNothing" instanceLockedExceptionAction="BasicRetry" instanceEncodingOption="GZip" hostLockRenewalPeriod="00:01:00"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<standardEndpoints>
  <dynamicEndpoint>
    <standardEndpoint name="ClientServiceDMZDynamicEndpointConfiguration">
      <discoveryClientSettings>
        <endpoint kind="udpDiscoveryEndpoint" endpointConfiguration="ServiceDMZUDPDiscoveryEndpoint"></endpoint>
      </discoveryClientSettings>
    </standardEndpoint>
  </dynamicEndpoint>
  <udpDiscoveryEndpoint>
    <standardEndpoint name="ServiceDMZUDPDiscoveryEndpoint" discoveryVersion="WSDiscovery11">
    </standardEndpoint>
  </udpDiscoveryEndpoint>
</standardEndpoints>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<diagnostics performanceCounters="All">
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="30000" maxSizeOfMessageToLog="2000000">
  </messageLogging>
</diagnostics>

ServiceDMZ

<system.serviceModel>
<services>
  <service name="ServiceDMZ" behaviorConfiguration="ServiceDMZBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://10.169.24.14:9100/"/>
      </baseAddresses>
    </host>
    <endpoint address="http://10.169.24.14:9100/ServiceDMZ" binding="wsHttpContextBinding" contract="IServiceDMZ" bindingConfiguration="ServiceDMZBinding" behaviorConfiguration="ServiceDMZEndpointBehavior" />
    <endpoint address="http://10.169.24.14:9100/ServiceDMZ/mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
    <endpoint name="udpDiscovery" kind="udpDiscoveryEndpoint" />
  </service>
</services>
<bindings>
  <wsHttpContextBinding>
    <binding name="ServiceDMZBinding" clientCallbackAddress="http://10.204.78.16:9101/ServiceDevCallback">
      <security>
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
        <transport clientCredentialType="Windows" realm="" proxyCredentialType="None"/>
      </security>
    </binding>
  </wsHttpContextBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceDMZBehavior">
      <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true"/>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDiscovery>
        <announcementEndpoints>
          <endpoint kind="udpAnnouncementEndpoint" />
        </announcementEndpoints>
      </serviceDiscovery>
    </behavior>
  </serviceBehaviors>

  <endpointBehaviors>
    <behavior name="ServiceDMZEndpointBehavior">
      <endpointDiscovery>
        <scopes>

        </scopes>
      </endpointDiscovery>
    </behavior>
  </endpointBehaviors>
</behaviors>

<standardEndpoints>
  <udpDiscoveryEndpoint>
    <standardEndpoint name="ServiceDMZUDPDiscoveryEndpoint" discoveryVersion="WSDiscovery11" maxResponseDelay="00:00:00.600"/>
  </udpDiscoveryEndpoint>
</standardEndpoints>

<diagnostics performanceCounters="All">
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="30000" maxSizeOfMessageToLog="2000000">        
  </messageLogging>
</diagnostics>    

1 个答案:

答案 0 :(得分:0)

这可能是部分信任问题。安全性是WCF要求完全信任完整功能,如果没有它只支持功能的子集,请参阅http://msdn.microsoft.com/en-us/library/bb412186.aspx

此外,如果您使用的是Windows身份验证,则需要域之间的信任,假设您的计算机位于不同的域中。