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
它将显示服务及其元数据。
热门推荐
10 病人祝福语老师寄语简短
11 新娘生孩子祝福语简短
12 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短