无法解析WCF"此服务的元数据发布目前已禁用"错误

时间:2013-07-11 04:29:40

标签: vb.net wcf web-services .net-4.0

我正在分支到.Net网络服务,不幸的是我是一个新手。由于在线推荐,我决定构建WCF服务而不是asp.net服务。我的最终目标是学习iOS和其他移动编程。我熟悉vb.net和c#标准和Web应用程序。

尝试从URL进行测试时,我收到“此服务的元数据发布当前已禁用”错误。我已经研究并试图为这个问题实施“修复”,但仍然很短。有人可以看看我的代码,看看我做错了什么?

Webconfig文件

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" strict="false" 
                 explicit="true" targetFramework="4.0" />
    <customErrors mode="Off"/>
  </system.web>
  <connectionStrings>
  </connectionStrings>
  <system.serviceModel>
<services>
<services>
<service name="CCT_Main_SRV.Service1" behaviorConfiguration="BehConfig">
<endpoint address="" binding="webHttpBinding" contract="CCT_Main_SRV.Service1" behaviorConfiguration="web">
</endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="BehConfig">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
    </serviceHostingEnvironment>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

.VB文件

Imports System.ServiceModel
Imports System

Namespace CCT_Main_SRV.Service1

<ServiceContract()>
Public Interface CCT_Main_SRV

    <OperationContract()>
    <WebGet(UriTemplate:="Get_Device_Authenication", _
            RequestFormat:=WebMessageFormat.Json, _
            ResponseFormat:=WebMessageFormat.Json, _
            BodyStyle:=WebMessageBodyStyle.Wrapped)>
    Function Authenicate_Device_Manager(ByVal Device_Name As String, _
                                        ByVal Auth_Key As String) _
             As List(Of Device_Authenication)

    <WebGet()>
    <OperationContract()>
    Function Authenicate_Device_Manager_Non_JSON(ByVal Device_Name As String, _
                                                 ByVal Auth_Key As String) _
             As List(Of Device_Authenication)
End Interface

<DataContract()>
Public Class Device_Authenication

    <DataMember()>
    Public Property Device_Name As String
    <DataMember()>
    Public Property Active As Boolean
    <DataMember()>
    Public Property Return_String As String
End Class

svc.vb文件

Imports System.ServiceModel
Imports System.Web.Script.Serialization
Imports System.ServiceModel.Activation
Imports System.ServiceModel.Web
Imports System.ServiceModel.Description


Namespace CCT_Main_SRV.Service1
    Public Class Service1
        Implements CCT_Main_SRV


    Dim host As WebServiceHost = New WebServiceHost(GetType(Service1), New Uri("http://pmh-vmutility-1/cct_web_srv_test/:8000/"))
    Dim ep As ServiceEndpoint = host.AddServiceEndpoint(GetType(CCT_Main_SRV), New WebHttpBinding(), "")


        Public Function Authenicate_Device_Manager(ByVal Device_Name As String, _
                                               ByVal Auth_Key As String) _
           As List(Of Device_Authenication) _
           Implements CCT_Main_SRV.Authenicate_Device_Manager

        End Function
    End  Class
End Namespace

1 个答案:

答案 0 :(得分:0)

service name="CCT_Main_SRV.Service1"

应该是:

service name="Service1"

或者它是否驻留在Web应用程序中:

service name="ProjectName.Web.Service1"

它应与服务的完全限定名称相匹配

{namespace}.{class}你的名字空间没有。