eid*_*lon 38 ssl https wcf wcf-binding
好吧,我必须在这里遗漏一些完全简单的东西,因为我已经在谷歌上搜索了几天,在那里看了几十个答案,而且在这里,我无论如何都无法实现这一点.通过普通HTTP调用时,该服务工作正常.
这是我们的设置......我们有一个域名,http://www.mydomain.com.我们在该域上安装了SSL证书,就像我们保护电子商务网站一样.一切正常,我可以去http s://www.mydomain.com,它的工作正常.我在Windows Server 2003 R2上运行VS2008,.NET 3.5站点.
现在,我向我的站点添加了启用Silverlight的WCF服务,我希望通过SSL进行通信.如果我浏览到http s://www.mydomain.com/myservice.svc,它会向我显示WSDL描述性的" 您已创建服务 "页面,其中显示了使用
svcutil.exe https:// ...
Run Code Online (Sandbox Code Playgroud)
编辑:我意识到在wsdl文件中为svcutil显示的url实际上是指向Web服务器的物理盒名称,而不是正确的域.所以我完成了这篇博客文章中显示的步骤,使用adsutil脚本更新IIS中网站的SecureBinding.现在wsdl文件显示正确的SSL地址,但我仍然得到相同的错误.
现在我去试图挂钩我的Silverlight应用程序,它不起作用,在异步调用的结果中返回一个异常,说" 远程服务器返回错误:NotFound.我的一些博客阅读谈到通过创建测试Windows应用程序将其缩小到Silverlight问题,并试图从中引用它.好吧,我做到了,甚至在试图通过SSL访问服务的常规Windows应用程序中我得到一个例外说明:
System.ServiceModel.EndpointNotFoundException:
There was no endpoint listening at https://www.mydomain.com/mysubdir/myservice.svc that could accept the message.
This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details. --->
System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Run Code Online (Sandbox Code Playgroud)
尽管我使用HTTPS方案明确地将服务引用添加到Windows应用程序,但它正确地获取了所有方法,并在编辑器中的Intellisense中显示它们.
请注意,这是一项不需要在用户身上显式登录的服务.我将在我的SOAP信封中发送自定义标头,以验证请求是否来自我们的应用程序,我只想让掠夺者嗅探线并挑出自定义标头.
现在到代码,我必须有一些愚蠢的小设置错误,因为从我读过的所有内容,这应该是一个相当简单的练习.
首先,我的服务的代码隐藏类使用以下属性进行修饰:
<ServiceBehavior(AddressFilterMode:=AddressFilterMode.Any)>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Run Code Online (Sandbox Code Playgroud)
我在服务器上的web.config的ServiceModel部分如下所示:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding">
<security mode="Transport">
<transport clientCredentialType ="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="standingsBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.mydomain.com:80"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="standingsBehavior" name="lijslwebdata">
<endpoint address="" binding="basicHttpBinding" contract="lijslwebdata"/>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我的Windows应用程序中app.config的ServiceModel部分如下所示:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_lijslwebdata" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://www.mydomain.com/mysubdir/myservice.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_lijslwebdata"
contract="xdata.lijslwebdata" name="BasicHttpBinding_lijslwebdata" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
小智 27
我最后也有同样的问题.你的帖子帮助我找出了问题所在.这是我的服务模型部分.我发现密钥是httpsGetEnabled然后设置绑定配置我希望这会有所帮助.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="RequestImageBehavior">
<serviceMetadata **httpsGetEnabled**="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="1073741824" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="RequestImageBehavior" name="RequestImage">
<endpoint address=""
binding="wsHttpBinding"
**bindingConfiguration**="HttpsBinding"
contract="IRequestImage">
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
**<wsHttpBinding>
<binding name="HttpsBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>**
</bindings>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
Joh*_*paw 11
我最近正在处理这个问题,并希望添加一个调整.如果您按照上述说明操作,则可以使该服务使用HTTPS,但不能同时使用HTTP和HTTPS.为此,您需要有两个端点配置节点,每个协议对应一个节点,如下所示:
<service name="MyCompany.MyService" >
<endpoint address="" behaviorConfiguration="AspNetAjaxBehavior"
binding="webHttpBinding" contract="MyCompany.MyService" bindingConfiguration="sslBinding" />
<endpoint address="" behaviorConfiguration="AspNetAjaxBehavior"
binding="webHttpBinding" contract="MyCompany.MyService" />
</service>
Run Code Online (Sandbox Code Playgroud)
(取自我的代码库,根据需要调整behaviorConfiguration和binding)
我刚刚花了几个小时才知道这个问题就是服务名称
<services>
<service name="TimberMill.Web.Data.LogReceiverService">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding"
contract="NLog.LogReceiverService.ILogReceiverServer" />
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
必须与我的*.svc文件中的类似条目完全匹配.
<%@ ServiceHost
Language="C#"
Debug="true"
Service="TimberMill.Web.Data.LogReceiverService, TimberMill.Web"
Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf"
CodeBehind="LogReceiverService.svc.cs"
%>
Run Code Online (Sandbox Code Playgroud)
我不确定它是否与我使用Autofac有关.这一切都在普通的HTTP下工作正常.但是在HTTPS下失败了.
嗯,我想是的,我现在不想通过更详细的测试来打扰任何事情,以免我愤怒的WCF-Config众神和我的配置再次破坏.因人而异.
在我的情况下,这些答案都没有帮助。
相反,我需要添加一个<binding>没有name属性 set的重复部分。
这是我服务的 web.config 文件相应部分的转储:
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata
httpsGetEnabled="true"
httpsGetUrl="RemoteSyncService.svc"
httpGetBindingConfiguration="bindingConfig" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata
httpsGetEnabled="true"
httpsGetUrl="RemoteSyncService.svc" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="bindingConfig" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
<!-- Add binding with EMPTY/MISSING name, see https://forums.iis.net/t/1178173.aspx -->
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
我确实希望有一天这可能对某人有所帮助。
好吧,我显然解决了这个问题,但我完全不知道为什么/如何解决。
这就是我所做的。
为什么这个解决了它,我完全不知道。
FWIW 对于任何人来说,这是我的新 web.config ServiceModel 部分,其中包含第二个服务......
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding">
</binding>
<binding name="basicHttpsBinding">
<security mode="Transport">
<transport clientCredentialType ="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="standingsBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.mydomain.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="standingsBehavior" name="lijslwebdata">
<endpoint address="" binding="basicHttpBinding" contract="lijslwebdata"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
<service behaviorConfiguration="standingsBehavior" name="sslwebdata">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="sslwebdata"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43809 次 |
| 最近记录: |