Wshttpbind 翻译为 basic
我有一个由两个项目组成的 WCF 服务:
- WCF 服务库
- WCF Web 应用程序
第一个项目有一个由 MyService 实现的服务调用 IMyService。它是通过使用 WS 绑定进行配置的,如果我在此项目上按 F5,WCFTestClient 将呈现 WS 绑定。 在 Web 应用程序中,我有一个 .svc 文件,其中包含同名的标记。
<%@ ServiceHost Language="C#" Debug="true" Service="[Namespace].MyService" %>
如果我在此项目上按 F5,它将呈现 BasicHttpBinding。在客户端中也是如此。 为什么?
I have a WCF service composed by two projects:
- WCF service library
- WCF Web application
The First project has a service call IMyService implemented by MyService. It is configured by using WS binding and if I press F5 on this project the WCFTestClient render the WS binding.
In the web app I have an .svc file with this markup with the same name
<%@ ServiceHost Language="C#" Debug="true" Service="[Namespace].MyService" %>
If I press F5 on this project it renders a BasicHttpBinding. Same in the Client.
Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚检查过 WCF 服务库项目默认创建 app.config,并将
WSHttpBinding
用于默认服务。当您运行 WCFTestClient 时,它始终使用此本地配置。如果您想使用 WCFTestClient 测试其他服务,您必须将其配置添加到此配置中。此配置从未用于其他任何用途。WCF 服务应用程序使用 web.config。在 WCF 4.0 中,它使用简化的配置,根据一些预定义的条件添加端点。默认情况下,它将
BasicHttpBinding
端点添加到使用公共ServiceHostFactory
通过 HTTP 公开的所有服务。I have just checked that WCF Service Library project by default creates app.config with
WSHttpBinding
used for default service. When you run WCFTestClient it always uses this local config. If you want to use WCFTestClient to test additional services you must add their configuration to this config. This config is never used for anything else.WCF Service application uses web.config. In WCF 4.0 it uses simplified configuration which adds endpoints based on some predefined conditions. By default it adds
BasicHttpBinding
endpoint to all services exposed over HTTP with commonServiceHostFactory
.你的配置文件是如何配置的?如果您将端点配置为使用 wshttpbinding,则应使用此端点。
您介意在此处添加一些代码(包括配置文件中的绑定和端点详细信息),以便我们看一下吗?
谢谢,
罗伯托·洛佩斯.
How is your config file configure? If you configure the endpoint to use the wshttpbinding, this is the one that should be used.
Would you mind adding some code here (including the binding and endpoint details from the config file), so we could take a look?
Thanks,
Roberto Lopes.
我认为最初的问题提出得非常糟糕,要获得满意的答案,您需要清楚地说明所有细节。
首先,您使用的是哪个版本的 Visual Studio?由于没有提及,我假设它是带有 SP1 的最新版本 VS2010。
假设您有一个包含两个项目的 Visual Studio 解决方案,一个是 WCF 服务库,另一个是 WCF 应用程序,这两个项目都是使用默认项目模板创建的,无需任何手动调整。
简而言之,Visual Studio 2010 (SP1) 默认使用 wsHttpBinding 进行 WCF 服务库项目。
OP 说“当我在这个项目上按 F5 时......”,这是一个非常误导性的陈述。
“在项目上按 F5”是什么意思?您的意思是您在解决方案树中选择了项目节点,然后按了 F5 吗?如果是这种情况,发生的情况将始终取决于解决方案中将哪个项目设置为启动项目(而不取决于当前在 Visual Studio UI 中选择的项目节点)。
如果WCF服务应用程序项目是启动项目,按F5不会导致WCF测试客户端运行,而是会导致该项目的文件夹显示在IE中。
如果WCF服务库项目是启动项目,则会运行WCF测试客户端,这只是因为在项目属性窗口的调试部分,启动选项默认有以下内容:
/客户端:“WcfTestClient.exe”
I believe the original question was very poorly posed, to get a satisfactory answer you need to clearly state all the details.
First which version of Visual Studio are yo using? Since nothing is said, I'll assume it's the latest version VS2010 with SP1.
Let's say you have a visual studio solution that has two projects, one is a WCF Service Library, another is a WCF Application, both created using the default project template without any manual tweaking.
in short, Visual Studio 2010 (SP1) uses wsHttpBinding for WCF Service Library projects by default.
The OP said "When I pressed F5 on this project ....", this is a very misleading statement.
What does it mean to "press F5 on a project"? Do you mean you selected the project node in the solution tree, then pressed F5? if that's the case, what happens will always depend on which project is set as the start-up project in the solution (not on which project node is currently selected in Visual Studio UI).
If the WCF Service Application project is the start-up project, pressing F5 will NOT cause the WCF test client to run, instead, it will cause the folder of the project to be displayed in IE.
If the WCF Service Library project is the start-up project, the WCF test client will be run, and this is only because in the debug section of the project's properties window, the start options has the following by default:
/client:"WcfTestClient.exe"