Abp Wcf combined use problem

After learning Abp for a few days, I probably have a relatively simple memory of Abp. Since I have been exposed to DDD-related content before, my learning is relatively smooth.

However, there are still various bugs when building the Wcf service...

1.No component for supporting the service Abp.Web.Localization.ICurrentCultureSetter was found...

This question was also raised on AbpGithub. The solution is also simple. It is to add the injection of the Apb module AbpWebApiModule in the WcfModule.

Github link https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2463

2. The Application interface cannot be injected in the service .svc file.

  •   Kernel was null, did you forgot to call DefaultServiceHostFactory.RegisterContainer() ? Parameter name: Kernel
    adds code to the Global file
            protected override void Application_Start(object sender, EventArgs e)
            {  AbpBootstrapper.IocManager.IocContainer.AddFacility<WcfFacility>()
                    .Register(
                        Component.For<ErrorHandlerBehavior>().Attribute("scope").Eq(WcfExtensionScope.Services)
                    );
    
                base.Application_Start(sender, e);
            }
  • The provided service type cannot be loaded as a service because it has no default (missing parameter) constructor. To fix this, add a default constructor to the type or pass an instance of the type to the host. Add Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory,Castle.Facilities.WcfIntegration"
    to the .svc service file you created. This is the Castle injection factory that comes with Abp.

     At the same time, Wcf service injection is performed in WcfModule. Example

 1 using Abp.Modules;
 2 using Abp.WebApi;
 3 using Castle.Facilities.WcfIntegration;
 4 using Castle.MicroKernel.Registration;
 5 using System;
 6 using System.Collections.Generic;
 7 using System.Linq;
 8 using System.Reflection;
 9 using System.ServiceModel;
10 using System.Text;
11 using System.Threading.Tasks;
12 using Try.Wcf2;
13 
14 namespace Try
15 {
16     [DependsOn(typeof(TryApplicationModule), typeof(TryCoreModule), typeof(TryDataModule),typeof(AbpWebApiModule))]
17     public class TryWcfModule : AbpModule
18     {
19         public override void Initialize()
20         {
21             IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
22 
23             InitServices();
24         }
25 
26         /// <summary>
27         /// 注册WCF服务
28         /// </summary>
29         private void InitServices()
30         {
31             var basicHttpBinding = new BasicHttpBinding()
32             {
33                 MaxBufferPoolSize = 2147483647,
34                 MaxBufferSize = 2147483647,
35                 MaxReceivedMessageSize = 2147483647,
36             };
37 
38             var webHttpBinding = new WebHttpBinding()
39             {
40                 MaxBufferPoolSize = 2147483647,
41                 MaxBufferSize = 2147483647,
42                 MaxReceivedMessageSize = 2147483647,
43             };
44 
45             IocManager.IocContainer.Register
46                 (
47                      Component.For<IStudentService>()
48                      .ImplementedBy<StudentService>()
49                      .Named("StudentService")
50                      .AsWcfService(new DefaultServiceModel().AddEndpoints(WcfEndpoint.BoundTo(basicHttpBinding)).Hosted().PublishMetadata())
51                 );
52 
53             var factory = new WindsorServiceHostFactory<Castle.Facilities.WcfIntegration.Rest.RestServiceModel>(IocManager.IocContainer.Kernel);
54         }
55     }
56 }
View Code

And in the .svc, replace the content in the table tag Service with the service name you injected. I injected a StudentService service above, so I just fill in Service="StudentService" on the Service side. If the description is not clear enough, I will release my demo later.

At the same time, it is stated that the Demo is purely hand-built and not made with templates on the official website.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324842300&siteId=291194637