0

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

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

网络配置文件

<?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
4

1 回答 1

0
service name="CCT_Main_SRV.Service1"

应该:

service name="Service1"

或者,如果它驻留在 Web 应用程序中:

service name="ProjectName.Web.Service1"

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

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

于 2013-07-11T05:05:41.527 回答