2012-03-28 18 views
0

Silverlight対応のWCFサービスでSpring.Netを使用したいと考えています。私はサービス "User.svc"を作成し、Spring.Netと連携するように設定しました。これらのエラーが発生しました:Silverlight対応のWCFサービスでSpring.Netを使用するには?

'/'アプリケーションでサーバーエラーが発生しました。 ------------------------------------------------- -------------------------------

Composition proxy target must implement at least one interface. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more 

エラーコードとコードのどこに由来するかについての情報。

Exception Details: System.ArgumentException: Composition proxy target must implement at least one interface. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of 

例外は、以下の例外スタックトレースを使用して識別できます。

私にこれを教えてください。すべての関連ファイルは以下のとおりです。

User.svc

<%@ ServiceHost Language="C#" Debug="true" Service="Client.Web.WCFServices.User" CodeBehind="User.svc.cs" Factory="Spring.ServiceModel.Activation.ServiceHostFactory" %> 

User.svc.cs

[SilverlightFaultBehavior] 
[ServiceContract(Namespace = "http://Client.Web")] 
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
public class User 
{ 
    private string testdi = "abc"; 

[OperationContract] 
    public string Hello(string msg) 
    { 
     return msg; 
    } 

    [OperationContract] 
    public int GetUserFromFingerprint(string fpt) 
    { 
     return 1; 
    } 

    [OperationContract] 
    public string HelloSpring(string msg) 
    { 
     UserDao ud = new UserDao(); 
     Entities.User u = new Entities.User(); 
     u.Password = "abc"; 
     u.Group = new Entities.Group(); 
     ud.Save(u); 
     return this.testdi; 
    } 
} 

Spring.net設定ファイル

<object id="UserServiceHost" type="Spring.ServiceModel.Activation.ServiceHostFactoryObject, Spring.Services"> 
    <property name="TargetName" value="UserService" /> 
</object> 
<object id="UserService" singleton="false" type="Client.Web.WCFServices.User, Client.Web"> 
    <property name="testdi" value="qwe" /> 
</object> 

のWeb.config

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name=""> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <customBinding> 
      <binding name="Client.Web.WCFServices.User.customBinding0"> 
       <binaryMessageEncoding /> 
       <httpTransport /> 
      </binding> 
     </customBinding> 
    </bindings> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
           multipleSiteBindingsEnabled="true" /> 
    <services> 
     <service name="UserService"> 
      <endpoint address="" binding="customBinding" bindingConfiguration="Client.Web.WCFServices.User.customBinding0" 
         contract="Client.Web.WCFServices.User" /> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
</system.serviceModel> 

答えて

0

エラーはSpring.NetまたはSilverlightとは関係ありません。

WCFは、インタフェースとして実装されたコントラクトを使用します。あなたはインターフェースを持っていません。

[ServiceContract] 
public interface ISampleInterface 
{ 
// No data contract is requred since both the parameter 
// and return types are primitive types. 
[OperationContract] 
double SquareRoot(int root); 

// No Data Contract required because both parameter and return 
// types are marked with the SerializableAttribute attribute. 
[OperationContract] 
System.Drawing.Bitmap GetPicture(System.Uri pictureUri); 

// The MyTypes.PurchaseOrder is a complex type, and thus 
// requires a data contract. 
[OperationContract] 
bool ApprovePurchaseOrder(MyTypes.PurchaseOrder po); 
} 

ServiceContractとOperationContractは、インターフェイスを実装しているクラスではなく、インターフェイス上にあることに注意してください。

+0

こんにちは、私はあなたの解決策を試みましたが、それは助けになりません。そして、 "Factory =" Spring.ServiceModel.Activation.ServiceHostFactory ""という行をUser.svc.cs(Spring.Netのコントロール外に置いてください)という行を削除してもエラーは報告されません。 –

関連する問題