【问题标题】:WCF Service not publishing the wsdlWCF 服务未发布 wsdl
【发布时间】:2014-10-17 14:42:55
【问题描述】:

我对 WCF 服务很陌生,但我从来没有想过绑定和所有这些。我现在拥有的服务,如果在 WCFTestClient 中测试过,但不会公开 WSDL 以供其他应用程序使用,则可以正常工作。我不确定它是如何完成的。代码如下:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <basicHttpBinding>
    <binding name="DefaultBindingConfig">
      <!--<security mode="none">
        <transport clientCredentialType="none" />
      </security>-->

    </binding>
  </basicHttpBinding>
</bindings>

<services>
  <service name="Service.SecurityService">
    <endpoint address="" 
              name="SecurityServiceEndpoint" 
              binding="basicHttpBinding" 
              bindingConfiguration="DefaultBindingConfig" 
              contract="Service.Contracts.ISecurityService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

[ServiceContract]
  public interface ISecurityService
  {
    [OperationContract]
    ApplicationSecurity GetFunctionsAllowedForUser(string userName, string applicationName);    
}

我怎样才能使这个服务公开 WSDL?我对此很陌生。

【问题讨论】:

    标签: c# web-services wcf service wsdl


    【解决方案1】:

    以下行应该公开 wsdl 的元数据:

    <serviceMetadata httpGetEnabled="true"/>
    

    在您的浏览器中,转到svc 的任何网址,然后在其末尾添加?wsdl

    http://localhost:<Port>/<OptionalFolders/>MyService.svc?wsdl
    

    如果一切正常,你应该有一堆 XML。

    【讨论】:

    • 是的,我已经尝试过了,但是当我转到 localhost:8000/Service.svc?wsdl 时,它给了我一个 400 错误请求错误。我不确定是什么导致出错:/
    • 嗯,你的端口可能和我的不同。转到项目属性-> Web。查看是否有指定的端口或特定的文件夹地址。或者更好的是,使用 WCFTestClient 中的地址并将?wsdl 附加到末尾。
    • 是的,我已将服务的端口与这里的端口相同。但是,它仍然显示 400 Bad Request 错误。我试过去 /mex 或 ?wsdl 但两者都返回相同的:/这可能与我正在运行它的服务器有关吗?
    • 不知道。这不是我能帮忙的。对不起,祝你好运!
    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 2020-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    相关资源
    最近更新 更多