Как использовать Spring.Net с включенными в Silverlight службами WCF? - PullRequest
0 голосов
/ 28 марта 2012

Я хочу использовать Spring.Net с включенными в Silverlight службами WCF. Я создал сервис "User.svc" и настроил его для работы с 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>

1 Ответ

0 голосов
/ 28 марта 2012

Ошибка не связана с 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 находятся в интерфейсе, а не в классе, который реализует интерфейс.

...