SilverLight调用中的WCF错误 [英] WCF error in SilverLight call

查看:46
本文介绍了SilverLight调用中的WCF错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建我的第一个Silverlight应用程序,并使用WCF服务访问数据.我是Silverlight和WCF的新手.我有一个网页,该网页上有一个SilverLight控件,该控件进行WCF调用.

I am building my first Silverlight application and using a WCF service to access the data.  I am new to both Silverlight and WCF.  I have a web page with a SilverLight control on the page and this control makes the WCF call.

在我的Web项目中,我添加了一个Web服务,该服务返回List< string>并且我已经对结果进行了硬编码.在SilverLight项目中,我添加了服务参考.使用本地主机在我的计算机上运行时,一切正常运行 和ASP.net开发服务器.部署到我们的开发服务器后,我收到此运行时错误.

In my web project I have added a web service what returns a List<string> and I have hard-coded the results.  In the SilverLight project I have added a service reference.  Everything works as it should when running on my machine using localhost and the ASP.net development server.  I get this runtime error after deploying to our development server.:

“尝试向URI'https://myProjectdev.domain.com/myProjectNew/Webservices/myProjectUserInfo.svc'发出请求时发生错误.这可能是由于尝试在没有适当的跨域策略的情况下以跨域方式访问服务 或不适合SOAP服务的策略.您可能需要联系服务的所有者以发布跨域策略文件,并确保它允许发送与SOAP相关的HTTP标头.此错误也可能是由于使用内部 无需使用InternalsVisibleToAttribute属性就可以在Web服务代理中输入类型.请参阅内部例外以获取更多详细信息.

“An error occurred while trying to make a request to URI 'https://myProjectdev.domain.com/myProjectNew/Webservices/myProjectUserInfo.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.”


我在几个位置添加了ClientAccessPolicy.xml和crossdomain.xml文件,但它们不能解决问题.它们位于c:\ inetpub \ wwwroot,我的Web应用程序根目录中,甚至位于具有Web服务的文件夹中.


I have added ClientAccessPolicy.xml and crossdomain.xml files in several locations but they do not fix the problem.  They are in the c:\inetpub\wwwroot, my web-app root, and even the folder with the web service.

如果我在本地主机上运行该应用程序的Visual Studio版本,并且WCF调用了部署在我的开发服务器上的版本,则会收到此错误.如果导航到网站的开发服务器版本,也会出现相同的错误 调用Web服务器上的WCF.

I get this error if I run the Visual Studio version of the app, on local host, with the WCF calling the version deployed on my development server.  I also get the same error if navigate to the development server’s version of the web site (which calls WCF on the web server).

当我使用应用程序的Visual Studio版本连接到Web服务的Visual Studio版本(使用localhost和ASP.Net开发服务器)时,一切正常.

Everything works when I use the Visual Studio version of the app connecting to the Visual Studio version of the web service (using localhost and the ASP.Net Development server).

在web.config和ServiceReferences.ClientConfig中,我必须具有两个版本的条目–一个用于localhost,另一个用于启用SSL的开发服务器.如果总是根据应用程序的运行位置将其注释掉,则为一个版本. (在那儿 更好的方法?).

In the web.config and ServiceReferences.ClientConfig I have to have two versions of the entries – one for localhost and one for the SSL enabled dev server.  One version if always commented out based on where the app is running.  (Is there a better way?).

我可以直接导航到部署在开发服务器上的SVC,如下所示:
https://myProjectdev.domain.com/myProjectNew/Webservices/myProjectUserInfo.svc

I can navigate directly to the SVC deployed on the dev server as follows:
https://myProjectdev.domain.com/myProjectNew/Webservices/myProjectUserInfo.svc

我还可以如下导航至WSDL文件:
https://myProjectdev.domain.com/myProjectNEW/Webservices/myProjectUserInfo.svc?wsdl

I can also navigate to the WSDL file as follows:
https://myProjectdev.domain.com/myProjectNEW/Webservices/myProjectUserInfo.svc?wsdl


这是我的web.config条目(用于SSL的设置,并已部署在我的开发服务器上).
< system.serviceModel>
  <行为>
   < serviceBehaviors>
    <行为名称=""<
    < serviceMetadata httpsGetEnabled ="true"/>
    </行为>
   </serviceBehaviors>
   < endpointBehaviors>
    <行为名称="SSLEndpointBehavior">
    < enableWebScript/>
    </行为>
   </endpointBehaviors>
  </行为>
 
 
  < bindings>
  <b; webHttpBinding>
   < binding name =" DeployedBinding">
   < security mode =运输">
    < transport clientCredentialType =证书"
       realm ="/>
    </security>
   </binding>
  </webHttpBinding>
  </bindings>
 
  < serviceHostingEnvironment aspNetCompatibilityEnabled ="true"
   multipleSiteBindingsEnabled ="true"; />
 
  <服务>
   <服务名称="myProjectUserInfo">
    < endpoint address =""
     behaviorConfiguration ="SSLEndpointBehavior"
     binding ="webHttpBinding" bindingConfiguration ="DeployedBinding"
     contract ="myProjectUserInfo" />
   </service>
  </services>
 </system.serviceModel>


Here is my web.config entry (setup for SSL and deployed on my dev server).
<system.serviceModel>
  <behaviors>
   <serviceBehaviors>
    <behavior name="">
     <serviceMetadata httpsGetEnabled="true"/>
    </behavior>
   </serviceBehaviors>
   <endpointBehaviors>
    <behavior name="SSLEndpointBehavior">
     <enableWebScript />
    </behavior>
   </endpointBehaviors>
  </behaviors>
 
 
  <bindings>
   <webHttpBinding>
    <binding name="DeployedBinding">
     <security mode="Transport">
      <transport clientCredentialType="Certificate"
       realm=""/>
     </security>
    </binding>
   </webHttpBinding>
  </bindings>
 
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
   multipleSiteBindingsEnabled="true" />
 
  <services>
   <service name="myProjectUserInfo">
    <endpoint address=""
     behaviorConfiguration="SSLEndpointBehavior"
     binding="webHttpBinding" bindingConfiguration="DeployedBinding"
     contract="myProjectUserInfo" />
   </service>
  </services>
 </system.serviceModel>

 

这是我的ServiceReferences.ClientConfig条目(用于SSL的设置).
< configuration>
 < system.serviceModel>
  < bindings>
  < customBinding>
   < binding name =" CustomBinding_myProjectUserInfo">
    < binaryMessageEncoding/>
    < httpsTransport maxReceivedMessageSize ="2147483647" maxBufferSize ="2147483647"; />
   </binding>
  </customBinding>
  </bindings>
  < client>
  <端点地址=" https://myProjectdev.domain.com /myProjectNew/Webservices/myProjectUserInfo.svc "
                             binding ="customBinding" bindingConfiguration =" CustomBinding_myProjectUserInfo"
                             contract ="myProjectUserInfo.myProjectUserInfo"; name =" CustomBinding_myProjectUserInfo" />
  </client>
 </system.serviceModel>
</configuration>

Here is my ServiceReferences.ClientConfig entry (setup for SSL). 
<configuration>
 <system.serviceModel>
  <bindings>
   <customBinding>
    <binding name="CustomBinding_myProjectUserInfo">
     <binaryMessageEncoding />
     <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>
   </customBinding>
  </bindings>
  <client>
   <endpoint address="https://myProjectdev.domain.com/myProjectNew/Webservices/myProjectUserInfo.svc"
                binding="customBinding" bindingConfiguration="CustomBinding_myProjectUserInfo"
                contract="myProjectUserInfo.myProjectUserInfo" name="CustomBinding_myProjectUserInfo" />
  </client>
 </system.serviceModel>
</configuration>


我已经研究了3天.有人可以帮忙吗?


I have been researching this for 3 days.  Can anyone help?

谢谢,
  唐

Thanks,
   Don

推荐答案

我只是想让它现在开始工作.这只是一个测试项目.我使用了下面的策略文件,应该可以对所有文件打开.

I am just trying to get it working now.  It is only a test project.  I used the policy files below, which should make it open to everything.

 

clientaccesspolicy.xml

clientaccesspolicy.xml

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

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


crossdomain.xml


crossdomain.xml

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

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


这篇关于SilverLight调用中的WCF错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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