0
 <system.serviceModel>
    <services>
      <service
          name="myClass.IService1"  behaviorConfiguration="myService">
        <endpoint
          name="ep1"
          address="http://localhost:57582/Service1.svc"
          contract="IService1"
          binding="basicHttpBinding"
          />
        <endpoint 
             address="mex"
             binding="mexHttpBinding"
             contract="IMetadataExchange" />
      </service>
    </services>

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

但我仍然收到以下错误:: 无法添加服务。服务元数据可能无法访问。确保您的服务正在运行并公开元数据。

4

1 回答 1

1
  1. 您的服务名称IService1- 这看起来实际上可能是合同。如果您使用的是普通模板,则删除 IfromIService1

  2. 如果您是 IIS 托管,则可以删除address.svc 文件的位置,因为该位置自动成为该地址。

  3. 合约需要完全限定,包括合约接口的命名空间

有了这个,您的元数据应该从<.svc file location>?wsdl

于 2012-05-30T10:42:51.367 回答