从 Silverlight 通过 https 使用 WCF 服务 [英] Consuming WCF Service through https from Silverlight

查看:29
本文介绍了从 Silverlight 通过 https 使用 WCF 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

似乎一切正常,但是当它尝试从 WCF 调用异步方法时,它显示此异常(抱歉,它只是西班牙语):

<块引用>

Se ha producido un error al intentar realizar una seekud al URI'https://samsung/WCF40_SSL_Service/Service.svc'.Puede deberse a un犯罪意图una politica entre dominios adecuada en contexto una politica noapropiada para servicios SOAP.Es posible que necesite ponerse en与公共财产联系信息politica entre dominios y para asegurarse de que permiteenvarencabezados HTTP relacionados con SOAP.埃斯特错误 también puededeberse al uso de tipos internos en el proxy de servicios web sinutilizar el atributo InternalsVisibleToAttribute.旁观者信息,请咨询内部例外.

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

<块引用>

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

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

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

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

提前致谢!!!

服务器配置:

<配置><连接字符串><add name="SqlSecureConnection" connectionString="数据源=.;初始目录=aspnetdb;集成安全=SSPI"/></connectionStrings><system.web><roleManager enabled="true"/><认证模式=表单"/><编译调试="true" targetFramework="4.0"/><membership defaultProvider="MySqlMembershipProvider"userIsOnlineTimeWindow="15"><提供者><清除/><添加名称="MySqlMembershipProvider"type="System.Web.Security.SqlMembershipProvider"connectionStringName="SqlSecureConnection"应用名称=/"enablePasswordRetrieval="false"enablePasswordReset="false"requiresQuestionAndAnswer="false"requiresUniqueEmail="true"passwordFormat="散列"/></提供者></会员资格></system.web><system.serviceModel><服务><服务名称="WCF_SecureService.Service"行为配置=服务行为"><端点地址=""绑定=自定义绑定"bindingConfiguration="custBind"合同="WCF_SecureService.IService"></端点></服务></服务><绑定><自定义绑定><绑定名称="custBind"><security authenticationMode="UserNameOverTransport"></security><httpsTransport></httpsTransport></binding></customBinding></绑定><行为><服务行为><行为名称="ServBehave"><serviceMetadata httpsGetEnabled="True"/><serviceDebug includeExceptionDetailInFaults="true"/><serviceCredentials><用户名认证userNamePasswordValidationMode="MembershipProvider"membershipProviderName="MySqlMembershipProvider"/></serviceCredentials></行为></serviceBehaviors></行为><serviceHostingEnvironment multipleSiteBindingsEnabled="true"/></system.serviceModel><system.webServer><modules runAllManagedModulesForAllRequests="true"/></system.webServer></配置>

客户端配置:

<预><代码><配置><system.serviceModel><绑定><自定义绑定><绑定名称="CustomBinding_IService"><security authenticationMode="UserNameOverTransport"includeTimestamp="true"><secureConversationBootstrap/></安全><textMessageEncoding messageVersion="默认"writeEncoding="utf-8"/><httpsTransport maxReceivedMessageSize="2147483647"maxBufferSize="2147483647"/></binding></customBinding></绑定><客户><端点地址="https://samsung/WCF40_SSL_Service/Service.svc"binding="customBinding" bindingConfiguration="CustomBinding_IService"contract="MyRef.IService" name="CustomBinding_IService"/></客户端></system.serviceModel></配置>

解决方案

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

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

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

I'm trying this example code: http://www.dotnetcurry.com/ShowArticle.aspx?ID=624

Everything seems to be ok but when it tries to call the async method from the WCF it shows this exception (sorry it's just in spanish):

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 política entre dominios adecuada en contexto o una política no apropiada para servicios SOAP. Es posible que necesite ponerse en contacto con el propietario del servicio para publicar un archivo de política 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. Para obtener más información, consulte la excepción interna.

English translation from freetranslation.com (not sure it helps:)

An error has been produced upon trying to carry out a request to the URI 'https://samsung/WCF40_SSL_Service/Service.svc'. Due to an intent of access to a service of configuration among controls without a politics among adequate controls in context or a not appropriate politics for services SOAP. It is possible that need to be put in contact with the owner of the service to publish a file of politics between controls and to be assured that permits to send headlines HTTP related to SOAP. This error also due to the use of internal types in the proxy of services web without utilizing the attribute InternalsVisibleToAttribute. To obtain more information, consult the internal exception.

This seems to me like a "clientaccesspolicy.xml" problem but I'm pretty sure it's ok and it's been placed in the root path, in application path, its parent...

<?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>

I tried to see in fiddler if the application was sending the clientaccesspolicy.xml request but it isn't!!! It doesn't try to even find the file...

I think I must be missing something trivial but I can't realize what... Any idea??

Thanks in advance!!!

Server config:

<?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>

Client config:

<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>

解决方案

One possibility is that it is related to the SSL certificate.

It looks like you are running https against a development machine. The possible problems here are:

  • You have not installed a SSL certificate
  • You have installed a self signed SSL certificate but the client does not trust it

这篇关于从 Silverlight 通过 https 使用 WCF 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆