2012-04-10 6 views
0

私はWCFを試している初心者です。私はアンドロイドを使用してWCFにアクセスしようとしていますが、問題があり、私の調査によれば、JsonはWCFにアクセスする必要があるので、jsonに変更しようとしました。WCFのserviceHostingEnvironmentに関する未処理のエラー

Iは、オブジェクトタイプへのインターフェイスを変更し

The exception message is: The type 'AddItemService.Login', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..] 

私のインターフェース方法下記に示すエラーを有する開始:

[OperationContract] 
     [WebInvoke(Method = "POST", UriTemplate = "Login", BodyStyle = WebMessageBodyStyle.WrappedRequest, 
      ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 
     [Description("Returns the Login User ID")] 
     int GetUserId(Login login); 

私のweb.config:

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="AddItemService.Login" 
       behaviorConfiguration="RESTBehavior"> 
     <endpoint address="" 
        binding="webHttpBinding" 
        contract="AddItemService.ILogin" 
        behaviorConfiguration="MyEndpointBehavior"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="RESTBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="MyEndpointBehavior"> 
      <webHttp helpEnabled="true"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
</configuration> 

をIなぜそれがうまくいかないのか分からない。誰でも助けてくれますか?

+0

GetUserId操作の1つのパラメーターのパラメータータイプは「ログイン」ですが、サービスタイプも「ログイン」です。異なる名前空間に2つの異なるタイプがありますか?もしそうでなければ、それはあなたの問題かもしれません。サービス名はサービスの実装です。あなたのケースでは、AddItemService.ILogin – kmp

答えて

1

WCFサービスの.svcファイルで指定されたサービスタイプ(コードビハインドではなく実際のマークアップファイル)のようなサウンドは、存在しないサービスクラスタイプを参照しています。

Visual Studioで.svcファイルを右クリックし、[マークアップを表示]を選択すると、そのファイルのServiceHostディレクティブの 'Service'属性に、WCFサービスインターフェイスを実装するクラスの名前が含まれている必要があります。現時点では、それが存在しないAddItemService.Loginを参照しているような音がします。

関連する問題