本文介绍了"ServiceHost 仅支持类服务类型"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,我无法克服这个错误.我已经完成了搜索,但找不到任何 vb 示例.我在这个 web.config 上做错了什么?

For some reason I can't get past this error. I've done searching, but can't find any vb examples. What am I doing wrong with this web.config?

SalesTracking.svc

<%@ ServiceHost Language="VB" Debug="true" Service="SalesTracking.ISalesTracking" CodeBehind="SalesTracking.svc.vb" %>

SalesTracking.svc.vb

Imports GlobalDir
Imports System.Web.Script.Serialization
Imports System.Reflection
Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Threading
Imports System.ServiceModel.Activation


<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class WebService
   Implements ISalesTracking



   Public Function GetDataUsingDataContract(ByVal composite As ClientSideData) As ClientSideData Implements ISalesTracking.GetDataUsingDataContract

   End Function
End Class

Web.config

<?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings>
        <add name="dbconstring" connectionString="Data Source="" providerName="System.Data.SqlClient" />
    </connectionStrings>
  <system.web>
      <authentication mode="Windows" />
      <authorization>

          <allow roles="Domain Users" />
          <deny users="*" />
      </authorization>
          <customErrors mode="Off"/>

      <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />

  </system.web>
  <system.serviceModel>
      <behaviors>
          <serviceBehaviors>
              <behavior name="SalesTracking.WebServiceBehavior">
                  <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                  <serviceMetadata httpGetEnabled="true"/>
                  <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                  <serviceDebug includeExceptionDetailInFaults="true"/>
              </behavior>
          </serviceBehaviors>

          <!-- start addition -->
          <endpointBehaviors>
              <behavior name="ServiceAspNetAjaxBehavior" >
                  <enableWebScript/>
              </behavior>
          </endpointBehaviors>
          <!-- end addition -->

      </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      <services>
          <service behaviorConfiguration="SalesTracking.WebServiceBehavior"
            name="SalesTracking.WebService" >

              <endpoint address="localhost" behaviorConfiguration="ServiceAspNetAjaxBehavior"
                binding="webHttpBinding" bindingConfiguration="NewBinding0" name="SalesTracking.WebService"
                contract="SalesTracking.ISalesTracking">
              </endpoint>
              <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
      </services>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

推荐答案

Service 属性必须是实现,而不是接口.

Service attribute must be the implementation, not interface.

<%@ ServiceHost Language="VB" Debug="true" Service="SalesTracking.WebService" ....

这篇关于&amp;quot;ServiceHost 仅支持类服务类型&amp;quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:09