安全WCF Web服务问题 [英] Secure WCF Web Service Problem
本文介绍了安全WCF Web服务问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个需要放在安全服务器上的Web服务.我已经在网络配置中完成了此操作:
I am developing a web service that needs to sit on a secure server. I''ve done this in the web config:
<behaviors>
<serviceBehaviors>
<behavior name="StdBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding >
<binding name="secureBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="StdBehavior" name="A.DevelopmentSvc">
<host>
<baseAddresses>
<add baseAddress="https://blah/blah/CrisSvc"/>
</baseAddresses>
</host>
<endpoint address="/"
binding="basicHttpBinding"
bindingConfiguration="secureBinding"
name="devEndpoint" contract="CrisCodeWcf.ICrisSvc"
/>
<endpoint address="mex"
binding="mexHttpsBinding"
name="mexEndpoint"
contract="IMetadataExchange"
/>
</service>
</services>
...但是当我尝试浏览IE中的服务时收到此错误:
Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [https].
...but I get this error when I try to browse to the service in IE:
Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [https].
推荐答案
约翰,
我通常使用批处理文件直接运行svcutil.这有一些好处,其中最主要的是您不需要与正在运行的服务进行对话.
svcutil能够根据实现程序集中的服务定义生成所需的代码.
这是我用于此目的的批处理文件的内容:
Hi John,
I usually run svcutil directly, using a batch file. This has a few benefits, chief among them is that you don''t need to talk to a running service.
svcutil is capable of generating the required code based on your service definition from the implementation assembly.
Here is the contents of a batch file I use for this purpose:
SETLOCAL
rem set up path so svcutil can be found
call c:\usr\bin\initvc.cmd
SET ROOTDIR=C:\Src\AjaWorks\AjaWorks.Oracle.Tools
rem this is where the service implmentation assembly is located
SET WCFSERVICEDIR=%ROOTDIR%\Goodtech.Databox.DX.DataService\bin\Debug
SET WCFSERVICECLIENTDIR=%ROOTDIR%\Generated
rem this assembly contains types shared between the client and server
SET COMMONTYPESDLL=%ROOTDIR%\Generated\bin\Debug\Goodtech.Databox.DX.dll
cd %WCFSERVICECLIENTDIR%\wsdl
rem let svcutil generate wsdl
svcutil %ROOTDIR%\Goodtech.Databox.DX.DataService\bin\Debug\Goodtech.Databox.DX.DataService.dll
CD %WCFSERVICECLIENTDIR%\Client
rem let svcutil generate code ( service reference )
svcutil %WCFSERVICECLIENTDIR%\wsdl\*.wsdl %WCFSERVICECLIENTDIR%\wsdl\*.xsd /namespace:*,Goodtech.Databox.DX.Client /targetClientVersion:Version35 /language:C# /ct:System.Collections.Generic.List`1 /out:DataServiceReference.cs /config:GeneratedApp.config /reference:%COMMONTYPESDLL%
ENDLOCAL
一个典型的解决方案通常至少具有:
- 用于在客户端和服务器之间共享的类型的程序集
- 用于服务实现的程序集
- 托管服务实现的Windows窗体应用程序-用于开发目的
- 承载服务实现的Windows服务(用于部署)
- 客户端API程序集,其中封装了svcutil生成的代码,添加了日志记录,连接处理等.
- 客户端应用程序
- An assembly for types shared between client and server
- An assembly for the service implementation
- A windows forms application that hosts the service implementation - for development purposes
- A windows service that hosts the service implementation - for deployment
- A client API assembly that wraps the code generated by svcutil, adds logging, connection handling, etc.
- The client application
A typical solution will usually have at least:
找到了这些修复线程(可能您会看到这些修复线程),但是每个线程都有许多解决方案
HTTPS所需的WCF绑定 [ ^ ]
https出现WCF错误:找不到与方案https匹配的基地址. [如何在WCF中修复找不到与模式http匹配的基地址" [ WCF Http绑定,需要SSL [
Found these fix threads(Possibly you might seen these), but every thread has number of solutions
WCF Bindings Needed For HTTPS[^]
https with WCF error: "Could not find base address that matches scheme https"[^]
How to fix "could not find a base address that matches schema http"… in WCF[^]
WCF Http Bindings, Require SSL[^]
您似乎可以请勿在https的绑定下使用basicHttpBinding,请检查此链接是否存在完全相同的问题并使用了webhttpbinding.
HTTPS所需的WCF绑定 [ ^ ]
It appears that you can''t use the basicHttpBinding under the bindings for https, check this link where they had the exact same problem and used webhttpbinding.
WCF Bindings needed for HTTPS[^]
这篇关于安全WCF Web服务问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文