【发布时间】:2014-06-19 13:42:15
【问题描述】:
对于长篇大论,我深表歉意... 我们有一个在组织内部使用的用 .Net 4.0 编写的 WCF 服务。最近,需要在组织网络之外提供此服务。因此,网络人员使用反向代理使该服务在组织外部可用。这是它的设置图片。
如图所示,http://mywebservice.com/readd.svc 服务托管在 WIndows 2008 R2 上,其内部 IP 地址为 XXX.YYY.ZZZ.RRR。该服务托管在端口 80 上。
有什么问题?
在内部,我可以使用 WCFTestClient 和浏览器以 http://mywebservice.com/readd.svc 的身份访问该服务。但是在组织之外,如果我输入 http://mywebservice.com/readd.svc 我得到“404 文件找不到错误”,而在 WCFTestCleint 中我得到错误为“错误:无法从 http://mywebservice.com/readd.svc 获取元数据……”。
但是,如果我像在浏览器中一样输入服务,我会看到显示肥皂链接的屏幕,如下所示。请忽略 LookUpService.svc 名称不匹配。
如上图所示...地址栏是 https ,但肥皂链接是 http 。如果我单击 http 链接 http://.... ?wsdl ,我会得到 not found 错误。这是因为反向代理只允许以 https 方式连接。
如果我使用 WCFTextClient 并将服务添加为https://mywebsite.com/readd.svc,我会收到如下错误。
“错误:无法从https://mywebsite.com/readd.svc 获取元数据如果这是 Windows (R)
您有权访问的通信基础服务,请检查您是否拥有
在指定地址启用元数据发布。如需帮助启用元数据发布,
请参阅http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange 错误处的 MSDN 文档
URI:http://mywebsite.com/readd.svc 元数据包含无法解析的引用:
'https://mywebsite.com/readd.svc'。内容类型应用程序/soap+xml;不支持 charset=utf-8
通过服务https://mywebsite.com/readd.svc.
客户端和服务绑定可能不匹配。
远程服务器返回错误:(415) OK.HTTP GET Error
URI:https://mywebsite.com/readd.svc
无法识别 URL http://mywebsite.com/readd.svc 处的文档
作为已知文档类型。每种已知类型的错误消息可能会对您有所帮助
解决问题:- 来自“XML Schema”的报告是
'无法识别文档格式(内容类型为'text/html; charset=UTF-8')。'.-
来自“http://mywebsite.com/readd.svc”的报告是
'无法识别文档格式(内容类型为'text/html; charset=UTF-8')。'.-
来自“DISCO 文档”的报告是“下载“http://mywebsite.com/readd.svc?disco”时出错。”。 -
请求失败,HTTP 状态为 404:未找到。- 来自“WSDL 文档”的报告是“无法识别文档格式(内容类型为 'text/html; charset=UTF-8')。”。 "
网络人员通知我以 https 的形式提供服务。这是我的 web.config 文件
<behaviors>
<serviceBehaviors>
<behavior name="ServiceLookup.LookupServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceLookup.LookupServiceBehavior" name="SmallApp.ServiceLookUp.LookUpService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BSBindingConfig" name="SmallApplianceBSEndPoint"
contract="SmallApp.ServiceLookUp.ILookupService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<!-- Remove this during deployment-->
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>-->
您能否建议我如何解决此问题..以便组织外部的用户可以使用 WCFTestCleint 作为 http/https 访问 api。
更新了 web.config 文件
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceLookup.LookupServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceLookup.LookupServiceBehavior" name="SmallApp.ServiceLookUp.LookUpService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BSBindingConfig" name="SmallApplianceBSEndPoint"
contract="SmallApp.ServiceLookUp.ILookupService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<!-- Remove this during deployment-->
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
我仍然在组织网络外部以 http 或 https 访问时出现错误
【问题讨论】:
-
谁能帮助我?
-
我不想这么说,但你所经历的听起来是对的。您的 WCF 服务器是否设置为转换 SSL,或者转换是否已卸载到 RP 服务器?如果 RP 将 SSL 转换为明文并转发消息,则应为正常的 http 流量设置 WCF 服务器。但是您可以为 http 和 https 消息设置 mex 配置。
-
Brain..我对 SSL 的了解很差..您能否详细说明如何找出 WCF 服务器设置为翻译 SSL 还是将翻译卸载到 RP 服务器上?
-
bp,你会在配置文件中看到它。您会在安全模式下看到“传输”...从您的配置中看,您的 WCF 站点设置为接收正常(非 ssl 流量),因为 httpGetEnabled=True 而不是 httpsGetEnabled=True。我要做的是在您的服务器上设置 Fiddler 并捕获入站消息以查看您的消息是否正确传递。
-
Brain..我用新的 web.config 文件更新了我的帖子。仍然没有运气......你能建议吗?
标签: c# wcf iis-7.5 firewall reverse-proxy