2

我正在尝试将 workflowControlEndpoint 添加到我的 IIS 托管 XAMLX 服务中。我无法从客户端引用控制端点,我不断收到以下错误

请求失败,HTTP 状态为 404:未找到。元数据包含无法解析的引用:“http://localhost/Test.xamlx/wce”。内容类型应用程序/soap+xml;服务“http://mymachine/Test.xamlx/wce”不支持 charset=utf-8。客户端和服务绑定可能不匹配。远程服务器返回错误:(415)无法处理消息,因为内容类型'application/soap+xml; charset=utf-8' 不是预期的类型 'text/xml; 字符集=utf-8'..

我有以下 web.config。有人可以指出我缺少什么吗?感谢并感谢您的帮助....

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior>
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <bindings>
   <basicHttpBinding>
    <binding closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" transferMode="StreamedResponse">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" proxyCredentialType="Windows" />
      </security>
    </binding>
    <binding name="httpSecurityOff" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647"
             allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
             transferMode="Streamed" useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>
  <service name="Test">
    <endpoint address="" binding="basicHttpBinding" contract="IService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="wce" binding="basicHttpBinding"
              bindingConfiguration="httpSecurityOff" 
              contract="System.ServiceModel.Activities.IWorkflowInstanceMangement"
              kind="workflowControlEndpoint" />
  </service>
4

2 回答 2

1

我试图让 IWorkflowInstanceManagement 通过 WCF 测试客户端工作,但我永远无法让它找到元数据。所以我只是尝试通过代码与它进行通信。它对我有用。

我创建了一个新的 Workflow Service 项目,我的 web.config 如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <connectionStrings>
    <add name="ApplicationServices" connectionString="data source=localhost\SQLEXPRESS;Initial Catalog=WFS;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="workflowBehavior">
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <sqlWorkflowInstanceStore instanceCompletionAction="DeleteAll" 
                                    instanceEncodingOption="GZip" 
                                    instanceLockedExceptionAction="BasicRetry" 
                                    connectionStringName="ApplicationServices" 
                                    hostLockRenewalPeriod="00:00:20" 
                                    runnableInstancesDetectionPeriod="00:00:05" />
          <workflowInstanceManagement authorizedWindowsGroup="AS_Administrators" />
          <workflowUnhandledException action="Terminate" />
          <workflowIdle timeToPersist="00:01:00" timeToUnload="00:01:00" />
        </behavior>

        <behavior name="wceBehavior">
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>

    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

    <services>
      <service name="Service1" behaviorConfiguration="workflowBehavior">
        <endpoint binding="basicHttpBinding" address="" contract="IService" />
        <endpoint binding="basicHttpBinding" address="wce" kind="workflowControlEndpoint" />
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

然后我使用以下代码创建了一个控制台应用程序(我知道这不是使用 ChannelFactory 的最佳方式):

var binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
var channelFactory = new ChannelFactory<IWorkflowInstanceManagement>(binding);
var channel = channelFactory.CreateChannel(new EndpointAddress("http://localhost/WorkflowControlTest/Service1.xamlx/wce"));
channel.Cancel(new Guid("DE212DE0-6BFF-4096-BF30-F6ACB2923B50"));

我的工作流程只是在一个延迟几分钟的循环中运行。我能够通过 WCF 测试客户端启动工作流实例,然后从持久性数据库中获取工作流实例 ID,然后运行控制台应用程序以取消工作流。

于 2013-03-13T17:16:14.333 回答
0

转到“控制面板 > 程序和功能 > 打开或关闭 Windows 功能”并检查是否检查了以下功能:

  • .NET 框架 3.5
  • .NET Framework 4.5 高级服务 > WCF 服务
于 2013-08-23T14:48:21.810 回答