0

我已经使用 Silverlight 应用程序一个多月了,并且偶然发现了一个奇怪的问题。我有一个在 IIS 中运行的 WCF 服务,可从以下 URL 访问: https ://xyztestname.com/service1.svc

我能够在 Visual Studio 中使用它,当从 Visual Studio 部署时,能够从 WCF 服务获得正确的回调,并且一切正常。当我将包文件部署到与 IIS 中的 Service1.svc 相同的文件夹中时,WCF 服务没有正确命中。

请帮我解决这个问题:(!这是我的 web.config 文件。

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
 http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
 <binding name="BasicHttpEndpointBinding">
 <security mode="TransportCredentialOnly">
 <transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="InformationService.Service1">
<endpoint address="" binding="basicHttpBinding"     bindingConfiguration="BasicHttpEndpointBinding"
name="BasicHttpEndpoint" contract="InformationService.IService1">    
</endpoint>    
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
 <serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>

我不知道我哪里出错了。但是通过 Intranet 访问时相同的虚拟文件夹可以正常工作,但通过 Internet 访问时无法正常工作:(请帮助。

编辑: 检查客户端配置后,我发现 Visual Studio 自动将 URL 解析为 Intranet URL。当我改回 Internet URL 时,我收到了一个异常。

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

但是,我已将跨域和 clientaccesspolicy 文件复制到 IIS 中应用程序的根目录中。:( 请帮忙。

4

1 回答 1

0

您必须将应用程序部署到特定的 ip 和端口才能在 Internet 中使用它。我想你可以。

为此,您需要手动编辑 applicationhost.config 文件(编辑 bindingInformation '::')

要启动 iisexpress,您需要管理员权限

1 – Bind your application to your public IP address

通常,当您在 IIS Express 中运行应用程序时,只能在 http://localhost:[someport] 上访问它。为了从另一台机器访问它,它也需要绑定到您的公共 IP 地址。打开 D:\Users[YourName]\Documents\IISExpress\config\applicationhost.config 并找到您的站点。你会发现这样的东西:

 <site name="YOUR PROJECT NAME HERE" id="2">
     <application path="/"> 
     <virtualDirectory path="/" physicalPath="YOUR PHYSICAL PATH HERE"
             <binding protocol="http" bindingInformation="*:58938:localhost" />
    </bindings>
</site> 

在 中,添加另一行:

   <binding protocol="http" bindingInformation="*:58938:192.168.1.42" /> 

(但当然是你的 IP 和端口号)

    2 - Allow incoming connections

如果您运行的是 Windows 7,则几乎所有传入连接都被锁定,因此您需要专门允许到您的应用程序的传入连接。首先,启动管理命令提示符。其次,运行这些命令,将 192.168.1.42:58938 替换为您使用的任何 IP 和端口:

netsh http 添加 urlacl url=http://192.168.1.42:58938/ user=everyone

这只是告诉 http.sys 可以与此 url 交谈。

netsh advfirewall 防火墙添加规则名称="IISExpressWeb" dir=in 协议=tcp localport=58938 profile=private remoteip=localsubnet action=allow

这会在 Windows 防火墙中添加一条规则,允许本地子网上的计算机到端口 58938 的传入连接。

到这里,您现在可以在 Visual Studio 中按 Ctrl-F5,然后从另一台计算机浏览您的站点!

于 2012-12-09T11:35:49.747 回答