wcf 向服务添加元数据终结点
示例
SOAP服务可以发布描述客户端可以调用的方法的元数据。客户端可以使用诸如VisualStudio之类的工具来自动生成代码(称为客户端代理)。代理隐藏了调用服务的复杂性。要调用服务,只需在客户端代理上调用一种方法。
首先,您必须将元数据终结点添加到服务中。假设您的服务看起来与“第一个服务和主机”示例中定义的服务相同,则可以对配置文件进行以下更改。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service.Example" behaviorConfiguration="serviceBehaviour">
<endpoint address="mex" binding="mexHttpBinding" name="mexExampleService" contract="IMetadataExchange" />
<endpoint name="netTcpExample" contract="Service.IExample" binding="netTcpBinding" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9000/Example" />
<add baseAddress="http://localhost:8000/Example" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>mexHttpbinding通过http公开接口,因此现在您可以使用网络浏览器
http://localhost:8000/示例http://localhost:8000/示例?wsdl
它将显示服务及其元数据。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下