Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
某些用户的WCF错误_Wcf_Wcf Binding_Wcf Security - Fatal编程技术网

某些用户的WCF错误

某些用户的WCF错误,wcf,wcf-binding,wcf-security,Wcf,Wcf Binding,Wcf Security,我有一个Silverlight应用程序,它使用一些WCF服务。当我运行silverlight应用程序时,一切正常。另一个人可以很好地使用它,但是,大多数用户都会出错 “尝试向URI‘xxxxx’发出请求时出错。这可能是由于在没有适当的跨域策略或不适合SOAP服务的策略的情况下,试图以跨域方式访问服务。您可能需要联系服务的所有者以发布跨域策略文件,并确保它允许发送与SOAP相关的HTTP头。此错误也可能是由于在web服务代理中使用内部类型而未使用InternalsVisibleToAttribut

我有一个Silverlight应用程序,它使用一些WCF服务。当我运行silverlight应用程序时,一切正常。另一个人可以很好地使用它,但是,大多数用户都会出错

“尝试向URI‘xxxxx’发出请求时出错。这可能是由于在没有适当的跨域策略或不适合SOAP服务的策略的情况下,试图以跨域方式访问服务。您可能需要联系服务的所有者以发布跨域策略文件,并确保它允许发送与SOAP相关的HTTP头。此错误也可能是由于在web服务代理中使用内部类型而未使用InternalsVisibleToAttribute属性造成的。有关详细信息,请参阅内部异常。“

我启用了WCF跟踪,并在这些用户访问我的Silverlight应用程序时注意到一些错误:

1) 未找到配置评估上下文。 2) 内容类型application/soap+xml;charset=utf-8已发送到需要text/xml;charset=utf-8的服务

以下是我的配置文件:

WCF的服务器配置:

    <?xml version="1.0"?>
<configuration>
    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel"
                    switchValue="All"
                    propagateActivity="true">
                <listeners>
                    <add name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData= "c:\log\Traces.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
      <authentication mode="Windows"/>
      <identity impersonate="false"/>
      <customErrors mode="Off" />
  </system.web>
    <appSettings>

    </appSettings>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior>
                    <!-- 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="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
<?xml version="1.0"?>
<configuration>
    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel"
                    switchValue="All"
                    propagateActivity="true">
                <listeners>
                    <add name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData= "c:\log\Traces.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
      <customErrors mode="Off" />

      <authentication mode="Windows" />

  </system.web>
    <appSettings>

    </appSettings>
    <system.serviceModel>       
        <bindings>
            <basicHttpBinding>
                <binding name="MyBinding">
                    <security mode="TransportCredentialOnly">
                        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <services>
            <service name="CRMWCF.SLtoCRM" behaviorConfiguration="CRMBehavior">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="CRMWCF.ISLtoCRM" />
            </service>
            <service name="CRMWCF.SLtoSQL" behaviorConfiguration="CRMBehavior">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="CRMWCF.ISLtoSQL" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="CRMBehavior">
                    <!-- 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="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>

        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
 <system.webServer>
     <httpProtocol>
         <customHeaders>
             <add name="Access-Control-Allow-Origin" value="*"/>
             <add name="Access-Control-Allow-Method" value="GET,PUT,POST,DELETE,OPTIONS"/>
             <add name="Access-Control-Allow-Headers" value="Content-Type"/>
         </customHeaders>
     </httpProtocol>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

以下是我在silverlight中的客户端配置:

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_ISLtoCRM" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
                <binding name="BasicHttpBinding_ISLtoSQL" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://xxxx.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_ISLtoCRM" contract="SLCRMSrvc.ISLtoCRM"
                name="BasicHttpBinding_ISLtoCRM" />
            <endpoint address="http://yyyy.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_ISLtoSQL" contract="SLSQLSrvc.ISLtoSQL"
                name="BasicHttpBinding_ISLtoSQL" />
        </client>
    </system.serviceModel>
</configuration>

WCF服务托管在Windows Server 2008 R2上的IIS 6.1中。应用程序池设置为在特定用户下运行。托管管道模式为经典模式,并在IIS中的站点上启用匿名身份验证。所有其他身份验证均已禁用

这有什么帮助吗?我不知道为什么我自己和其他用户可以很好地访问应用程序,但大多数用户不能。这是安全问题还是我创建WCF服务的方式有问题

已更新WCF的服务器配置:

    <?xml version="1.0"?>
<configuration>
    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel"
                    switchValue="All"
                    propagateActivity="true">
                <listeners>
                    <add name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData= "c:\log\Traces.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
      <authentication mode="Windows"/>
      <identity impersonate="false"/>
      <customErrors mode="Off" />
  </system.web>
    <appSettings>

    </appSettings>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior>
                    <!-- 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="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
<?xml version="1.0"?>
<configuration>
    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel"
                    switchValue="All"
                    propagateActivity="true">
                <listeners>
                    <add name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData= "c:\log\Traces.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
      <customErrors mode="Off" />

      <authentication mode="Windows" />

  </system.web>
    <appSettings>

    </appSettings>
    <system.serviceModel>       
        <bindings>
            <basicHttpBinding>
                <binding name="MyBinding">
                    <security mode="TransportCredentialOnly">
                        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <services>
            <service name="CRMWCF.SLtoCRM" behaviorConfiguration="CRMBehavior">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="CRMWCF.ISLtoCRM" />
            </service>
            <service name="CRMWCF.SLtoSQL" behaviorConfiguration="CRMBehavior">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="CRMWCF.ISLtoSQL" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="CRMBehavior">
                    <!-- 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="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>

        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
 <system.webServer>
     <httpProtocol>
         <customHeaders>
             <add name="Access-Control-Allow-Origin" value="*"/>
             <add name="Access-Control-Allow-Method" value="GET,PUT,POST,DELETE,OPTIONS"/>
             <add name="Access-Control-Allow-Headers" value="Content-Type"/>
         </customHeaders>
     </httpProtocol>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

非常常见的问题。您需要clientaccesspolicy.xml和crossdomain.xml


Jeff,我确实有这些文件。请尝试将以下内容添加到您的服务web配置Jeff,我应用了您的更改,但没有更改结果。我已更新了我的原始帖子,以包含最新的配置文件。我已删除匿名访问并加入Windows身份验证,但具有ame问题。我可以上车,其他用户可以,但没有其他人。更新后,我胡乱设置,最终回收了应用程序池。现在我无法让应用程序与WCF服务通信。我还尝试删除对WCF服务的匿名访问,但这让我感到不适。我已经发布了一篇关于这一点的单独帖子。