【问题标题】:Consuming WCF Service through https from Silverlight通过 Silverlight 中的 https 使用 WCF 服务
【发布时间】:2011-11-14 17:43:25
【问题描述】:

我正在尝试这个示例代码: http://www.dotnetcurry.com/ShowArticle.aspx?ID=624

一切似乎都很好,但是当它尝试从 WCF 调用异步方法时,它显示了这个异常(对不起,它只是西班牙语):

Se ha producido un error al intentar realizar una solicitud al URI 'https://samsung/WCF40_SSL_Service/Service.svc'。 Puede deberse a un intento de acceso a un servicio de configuración entre dominios sin una politica entre dominios adecuada en contexto o una politica no apropiada para servicios SOAP。 Es posible que necesite ponerse en contacto con el propietario del servicio para publicar un archivo de politica entre dominios y para asegurarse de que permite enviar encabezados HTTP relacionados con SOAP。 Este error también puede deberse al uso de tipos internos en el proxy de servicios web sin utilizar el atributo InternalsVisibleToAttribute。为获得者提供更多信息 infoación, Consulte la excepción interna.

freetranslation.com 的英文翻译(不确定是否有帮助:)

在尝试对 URI“https://samsung/WCF40_SSL_Service/Service.svc”执行请求时产生错误。由于访问服务的意图 控制之间的配置,没有上下文中足够的控制之间的政治或服务 SOAP 的不适当的政治。可能需要与服务所有者联系以发布控件之间的政治文件并确保允许发送与 SOAP 相关的 HTTP 标题。此错误也是由于在服务 Web 代理中使用内部类型而未使用属性 InternalsVisibleToAttribute。要获取更多信息,请参阅内部异常。

在我看来,这就像一个“clientaccesspolicy.xml”问题,但我很确定它没问题,它已被放置在根路径、应用程序路径、其父级...

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from http-request-headers="*">
                <domain uri="*"/>
            </allow-from>
            <grant-to>
                <resource path="/" include-subpaths="true"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy>

我试图在 fiddler 中查看应用程序是否正在发送 clientaccesspolicy.xml 请求,但事实并非如此!!!它甚至不会尝试找到文件...

我想我一定遗漏了一些微不足道的东西,但我不知道是什么……有什么想法吗??

提前致谢!!!

服务器配置:

<?xml version="1.0"?>
<configuration>
    <connectionStrings>
        <add  name="SqlSecureConnection" connectionString="Data Source=.;
              Initial Catalog=aspnetdb;Integrated Security=SSPI"/>
    </connectionStrings>
    <system.web>
        <roleManager enabled="true" />
        <authentication mode="Forms" />
        <compilation debug="true" targetFramework="4.0" />

        <membership defaultProvider="MySqlMembershipProvider"  
                    userIsOnlineTimeWindow="15">
            <providers>
                <clear />
                <add
                  name="MySqlMembershipProvider"
                  type="System.Web.Security.SqlMembershipProvider"
                  connectionStringName="SqlSecureConnection"
                  applicationName="/"
                  enablePasswordRetrieval="false"
                  enablePasswordReset="false"
                  requiresQuestionAndAnswer="false"
                  requiresUniqueEmail="true"
                  passwordFormat="Hashed" />
            </providers>
        </membership>
    </system.web>
    <system.serviceModel>
        <services>
            <service name="WCF_SecureService.Service" 
                     behaviorConfiguration="ServBehave">
                <endpoint
                   address=""
                    binding="customBinding"
                    bindingConfiguration="custBind"
                    contract="WCF_SecureService.IService">
                </endpoint>
            </service>
        </services>
        <bindings>
      <customBinding>
        <binding name="custBind">
          <security authenticationMode="UserNameOverTransport"></security>
          <httpsTransport></httpsTransport>
        </binding>
      </customBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior  name="ServBehave">
                    <serviceMetadata  httpsGetEnabled="True"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceCredentials>
                        <userNameAuthentication
                           userNamePasswordValidationMode="MembershipProvider" 
                    membershipProviderName="MySqlMembershipProvider"/>
                    </serviceCredentials>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>  
</configuration>

客户端配置:

<configuration>
<system.serviceModel>
<bindings>
    <customBinding>
        <binding name="CustomBinding_IService">
            <security authenticationMode="UserNameOverTransport" 
                        includeTimestamp="true">
                <secureConversationBootstrap />
            </security>
            <textMessageEncoding messageVersion="Default" 
                                    writeEncoding="utf-8" />
            <httpsTransport maxReceivedMessageSize="2147483647" 
                            maxBufferSize="2147483647" />
        </binding>
    </customBinding>
</bindings>
<client>
    <endpoint 
        address="https://samsung/WCF40_SSL_Service/Service.svc"
        binding="customBinding" bindingConfiguration="CustomBinding_IService"
        contract="MyRef.IService" name="CustomBinding_IService" />
</client>

</system.serviceModel>

</configuration>

【问题讨论】:

  • 能否同时提供客户端和服务器配置?
  • 当然,他们来了 ;-)

标签: silverlight wcf


【解决方案1】:

一种可能是与SSL证书有关。

看起来您正在对开发机器运行 https。这里可能出现的问题是:

  • 您尚未安装 SSL 证书
  • 您已安装自签名 SSL 证书,但客户端不信任它

【讨论】:

  • 非常感谢您的回答!!!正如你所说,我正在使用我自己的开发机器来尝试这个例子,它有一个自签名的 SSL 证书。你知道如何强制我的客户信任证书吗??
  • 如果您在浏览器中浏览到 svc 文件,那么您应该会看到一个红色横幅,说明它不信任证书,请尝试单击该消息并选择在本地安装证书。您正在浏览的机器现在将信任该证书。
  • 这似乎行不通:-(。无论如何你知道要强制silverlight客户端避免这种检查吗?
【解决方案2】:

在浏览器中打开此网址时您会看到什么? https://samsung/WCF40_SSL_Service/Service.svc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多