我正在尝试使用nettcpbinding发布wcf服务.我想使用?wsdl发布元数据.我在配置文件中添加了以下行:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
Run Code Online (Sandbox Code Playgroud)
但我在浏览器中看不到wsdl.我做错了什么?谢谢.
编辑:这是我的配置文件的相关部分:
<system.serviceModel>
<services>
<service name="wcfcheck.service1" behaviorConfiguration="wcfcheck.Service1Behavior">
<endpoint address="" binding="netTcpBinding" contract="wcfcheck.Iservice1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfcheck.Service1Behavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
Run Code Online (Sandbox Code Playgroud)
我可能没有访问正确的URL.我尝试了http:// localhost:51159/Service1.svc?wsdl和http:// localhost:51159/Service1.svc/mex?wsdl,没有'?wsdl'.
Joh*_*ers 13
您需要使用该<serviceMetadata>元素.
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<!-- Enables the IMetadataExchange endpoint in services that -->
<!-- use "metadataSupport" in their behaviorConfiguration attribute. -->
<!-- In addition, the httpGetEnabled and httpGetUrl attributes publish -->
<!-- Service metadata for retrieval by HTTP/GET at the address -->
<!-- "http://localhost:8080/SampleService?wsdl" -->
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
Meh*_*ras 12
您需要通过http为wsdl发布服务元数据.将以下标记添加到配置文件的<system.serviceModel>标记中
<behaviors>
<serviceBehaviors>
<behavior name = "MetadataBehavior">
<serviceMetadata httpGetEnabled = "true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
您还需要指定一个http地址,其中wsdl中的服务元数据可用于该地址.将其添加到配置文件的<service>节点:
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001" />
<add baseAddress="http://localhost:8000/Service1" />
</baseAddresses>
</host>
Run Code Online (Sandbox Code Playgroud)
然后,如果你去http:// localhost:8000/Service1?wsdl,你应该看到你的服务的wsdl.
| 归档时间: |
|
| 查看次数: |
21895 次 |
| 最近记录: |