Base solution for your next web application
Open Closed

How to use WSDL service in MVC5AJ? #5506


User avatar
0
tteoh created

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: [attachment=0:2ixby69b]WhatsApp Image 2018-08-13 at 2.27.13 PM.jpeg[/attachment:2ixby69b]

The below code is shown what exception I'm getting:

{
  "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.


11 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    It looks like there is no problem. You can send the project code of the problem to my email: [email protected] I will download and check it out.

  • User Avatar
    0
    tteoh created

    Hi,

    I sent my WSDL service project and MVC5AJ project to you by my own email(<a href="mailto:[email protected]">[email protected]</a>).

    Hopefully, can get a good news from you.

    Thanks :)

  • User Avatar
    0
    alper created
    Support Team

    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.

  • User Avatar
    0
    tteoh created

    <cite>alper: </cite> 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: [attachment=0:2i1myobr]Capture.PNG[/attachment:2i1myobr]

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

    Thanks.

  • User Avatar
    0
    tteoh created

    Hi, @alper @maliming

    I solved the problem by adding to Web.config: [attachment=1:30xm49vc]WhatsApp Image 2018-08-13 at 6.06.06 PM.jpeg[/attachment:30xm49vc]

    But then I got a warning after I added the codes above to Web.config: [attachment=0:30xm49vc]WhatsApp Image 2018-08-13 at 6.06.07 PM.jpeg[/attachment:30xm49vc] 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.

  • User Avatar
    0
    alper created
    Support Team

    Yeah that's a standard WSDL configuration. I thought you have already done that.

  • User Avatar
    0
    tteoh created

    <cite>tteoh: </cite> Hi, @alper @maliming

    I solved the problem by adding to Web.config: [attachment=1:1fuktc5s]WhatsApp Image 2018-08-13 at 6.06.06 PM.jpeg[/attachment:1fuktc5s]

    But then I got a warning after I added the codes above to Web.config: [attachment=0:1fuktc5s]WhatsApp Image 2018-08-13 at 6.06.07 PM.jpeg[/attachment:1fuktc5s] 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
    0
    alper created
    Support Team

    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.

  • User Avatar
    0
    tteoh created

    <cite>alper: </cite> 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.

  • User Avatar
    0
    ismcagdas created
    Support Team

    I'm not sure how this is related to AspNet Zero ?

  • User Avatar
    0
    tteoh created

    <cite>ismcagdas: </cite> I'm not sure how this is related to AspNet Zero ?

    @ismcagdas Just the our practice to try specific functionality using standard template and then only apply to anz template. Mainly to skip the DI first.

    I don’t think this is directly related to aspnetzero. However, for some reason the warning didn’t appear when we tried using standard MVC project template from VS2017. But the warning appeared when applied the same codes in ANZ project template.

    It was for a requiement where we had to implement ExternalAuthentication (adopting LDAP approach) with external System via WSDL.

    Understand this is a grey area in term of support.

    Thanks. /tommy