Support forum for ASP.NET Zero (https://aspnetzero.com/).
By tteoh
#31440 Hi,

I'm using MVC5AJ. I'm trying to added WSDL service into my MVC5AJ1.

But I'm getting exception of my WSDL service class injection when I using swagger to called my App Service.

This is shown how I injected my WSDL service class in my App Service:
WhatsApp Image 2018-08-13 at 2.27.13 PM.jpeg
WhatsApp Image 2018-08-13 at 2.27.13 PM.jpeg (20.44 KiB) Viewed 1466 times


The below code is shown what exception I'm getting:
Code: Select all{
  "message": "An error has occurred.",
  "exceptionMessage": "ComponentActivator: could not proxy Abp.WebApi.Controllers.Dynamic.DynamicApiController`1[[MVC5AJ1Demo.CRMAuthentication.ICrmAuthenticationAppService, MVC5AJ1Demo.Application, Version=5.6.0.0, Culture=neutral, PublicKeyToken=null]]",
  "exceptionType": "Castle.MicroKernel.ComponentActivator.ComponentActivatorException",
  "stackTrace": "   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)\r\n   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)\r\n   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)\r\n   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)\r\n   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)\r\n   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)\r\n   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)\r\n   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)\r\n   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)\r\n   at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments)\r\n   at Castle.Windsor.WindsorContainer.Resolve(Type service)\r\n   at Abp.Dependency.IocManager.Resolve(Type type)\r\n   at Abp.Dependency.IocResolverExtensions.ResolveAsDisposable[T](IIocResolver iocResolver, Type type)\r\n   at Abp.WebApi.Controllers.AbpApiControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n   at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()",
  "innerException": {
    "message": "An error has occurred.",
    "exceptionMessage": "ComponentActivator: could not proxy MVC5AJ1Demo.CRMAuthentication.CrmAuthenticationAppService",
    "exceptionType": "Castle.MicroKernel.ComponentActivator.ComponentActivatorException",
    "stackTrace": "   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)\r\n   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)\r\n   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)\r\n   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)\r\n   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)\r\n   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)\r\n   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)\r\n   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)\r\n   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency)\r\n   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)\r\n   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)\r\n   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)\r\n   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)\r\n   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)\r\n   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)\r\n   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)\r\n   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)\r\n   at Castle.Core.InterceptorReference.Castle.MicroKernel.IReference<Castle.DynamicProxy.IInterceptor>.Resolve(IKernel kernel, CreationContext context)\r\n   at Castle.Windsor.Proxy.AbstractProxyFactory.ObtainInterceptors(IKernel kernel, ComponentModel model, CreationContext context)\r\n   at Castle.Windsor.Proxy.DefaultProxyFactory.Create(IKernel kernel, Object target, ComponentModel model, CreationContext context, Object[] constructorArguments)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)",
    "innerException": {
      "message": "An error has occurred.",
      "exceptionMessage": "Exception has been thrown by the target of an invocation.",
      "exceptionType": "System.Reflection.TargetInvocationException",
      "stackTrace": "   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)\r\n   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)\r\n   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)\r\n   at System.Activator.CreateInstance(Type type, Object[] args)\r\n   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyInstance(Type proxyType, List`1 proxyArguments, Type classToProxy, Object[] constructorArguments)\r\n   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)\r\n   at Castle.Windsor.Proxy.DefaultProxyFactory.Create(IKernel kernel, Object target, ComponentModel model, CreationContext context, Object[] constructorArguments)\r\n   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)",
      "innerException": {
        "message": "An error has occurred.",
        "exceptionMessage": "Could not find default endpoint element that references contract 'BasicHttpBinding_ICrmUserService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.",
        "exceptionType": "System.InvalidOperationException",
        "stackTrace": "   at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)\r\n   at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)\r\n   at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)\r\n   at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)\r\n   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)\r\n   at System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory()\r\n   at System.ServiceModel.ConfigurationEndpointTrait`1.CreateChannelFactory()\r\n   at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)\r\n   at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()\r\n   at System.ServiceModel.ClientBase`1..ctor()\r\n   at MVC5AJ1Demo.CrmDemoAuthenticationService.CrmUserServiceClient..ctor() in C:\\Users\\FTS01\\Desktop\\Demo Projects\\MVC5AJ1Demo\\src\\MVC5AJ1Demo.Application\\Connected Services\\CrmDemoAuthenticationService\\Reference.cs:line 156\r\n   at MVC5AJ1Demo.CRMAuthentication.CrmAuthenticationAppService..ctor() in C:\\Users\\FTS01\\Desktop\\Demo Projects\\MVC5AJ1Demo\\src\\MVC5AJ1Demo.Application\\CRMAuthentication\\CrmAuthenticationAppService.cs:line 15\r\n   at Castle.Proxies.CrmAuthenticationAppServiceProxy..ctor(IInterceptor[] )"
      }
    }
  }
}


So, what I need to know is how do I call WSDL service class method in my App Service?

Thanks.
User avatar
By alper
#31443 Check your CrmAuthenticationAppService.cs for injected classes. One of them is not registered to dependency injection system. You can remove them one by one to understand which one is the problem.
By tteoh
#31445
alper wrote:Check your CrmAuthenticationAppService.cs for injected classes. One of them is not registered to dependency injection system. You can remove them one by one to understand which one is the problem.


Hi,

WSDL service reference class is the 1 causes the problem:
Capture.PNG
Capture.PNG (92.21 KiB) Viewed 1459 times


So, can you teach me how to register the injected classes to dependency injection system??

Thanks.
By tteoh
#31451 Hi,
@alper @maliming

I solved the problem by adding to Web.config:
WhatsApp Image 2018-08-13 at 6.06.06 PM.jpeg
WhatsApp Image 2018-08-13 at 6.06.06 PM.jpeg (36.54 KiB) Viewed 1455 times


But then I got a warning after I added the codes above to Web.config:
WhatsApp Image 2018-08-13 at 6.06.07 PM.jpeg
WhatsApp Image 2018-08-13 at 6.06.07 PM.jpeg (12.88 KiB) Viewed 1455 times

I know it won't affect the function but just wonder to know why is this happening, because the warning is not appearing at normal ASP.NET MVC template.

Thanks.
By tteoh
#31477
tteoh wrote:Hi,
@alper @maliming

I solved the problem by adding to Web.config:
WhatsApp Image 2018-08-13 at 6.06.06 PM.jpeg


But then I got a warning after I added the codes above to Web.config:
WhatsApp Image 2018-08-13 at 6.06.07 PM.jpeg

I know it won't affect the function but just wonder to know why is this happening, because the warning is not appearing at normal ASP.NET MVC template.

Thanks.


@alper any idea why there is a warning message when using the WSDL in aspetzero where else the same WSDL does not throw any warning message when used in standard MVC template.

Appreciate your advice.
Tq
User avatar
By alper
#31488 Try

1) In the Solution Explorer, under the Service References folder, right-click the service reference name with the issue and select 'Configure Service Reference'.

2) The Service Reference Settings window will appear. Uncheck the box labeled 'Reuse types in referenced assemblies' and click the OK button.

3) Rebuild the project.

After rebuilding, the warning should disappear.
By tteoh
#31493
alper wrote:Try

1) In the Solution Explorer, under the Service References folder, right-click the service reference name with the issue and select 'Configure Service Reference'.

2) The Service Reference Settings window will appear. Uncheck the box labeled 'Reuse types in referenced assemblies' and click the OK button.

3) Rebuild the project.

After rebuilding, the warning should disappear.


Hi,

I have already followed the steps that you suggested but the warning is still appear.

Thanks.