Open Closed

Dynamic JavaScript API Client Proxies #2440


User avatar
0
Spospisil created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.4.4
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Tiered / MVC / Identity Server

I am getting an error in the browser when trying to call the API via the Dynamic Javascript Client Proxy. Below are screenshots for my service contract interface, implementation of that interface and the javascript file that refers to the api service and the error in the browser that I am getting when trying to use this api proxy.

Can you see from this what the issue might be? The last time this happened it seemed to be related to a naming convention of my namespace I was using but I have tried it using many ones at this point and I'm still getting the error.

Thanks


16 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You must make sure the Abp/ServiceProxyScript is loaded before you call the proxy js.

  • User Avatar
    0
    Spospisil created

    How do you mean? How do I do that?

    For some reason the only way I can make the javascript call to my 'applicationservice' is to define a controller for it that injects the application service and calls the method I want.

    The ServiceProxyScript when I view it in the browser does not include any of my solutions application services that I've created and that implement the IApplicationService interface.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Your JavaScript will not be available until this JS is loaded.

  • User Avatar
    0
    Spospisil created

    Hi,

    Understood, but I am using the lepton theme that is provided by Volvo/ABP and have not modified the placement of where this is loaded. The lepton theme's code defines where this reference is placed.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can you share a project that reproduces the problem? liming.ma@volosoft.com

    You can create a brand new via ABP CLI.

  • User Avatar
    0
    Spospisil created

    I have created a new solution using ABP Suite 5.1.2 and adding the Lepton theme module as a project (using ABP Suite) and adding my Company 'application service'. Run a migration to create the database, and then run the tiered projects. Select from the left nativation menu 'System' and then 'Company Maintenance'.

    The page should call my company application service 'CompanyHostAppService' method of 'GetCompanyListAsync' but instead it gets a similar error to the one shown in this thread.

    The Git repo for this same is below and you should have received an invite to the repo.

    https://github.com/spospisil/ABPSampleServiceError

  • User Avatar
    0
    Spospisil created

    Hi,

    Have you had a chance to take a look at this yet?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will check it today, sorry for the delay.

  • User Avatar
    0
    Spospisil created

    Hi,

    Thank you. Much appreciated.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    https://github.com/spospisil/ABPSampleServiceError/pull/1

  • User Avatar
    0
    Spospisil created

    Hi,

    I don't understand. Why is a controller necessary? Based on the documentation link below if you create the application service according to what the documentation shows, you don't need a controller.

    Please advise.

    https://docs.abp.io/en/abp/4.4/API/Auto-API-Controllers

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Why is a controller necessary?

    You are using the tiered project, but enable the Auto API Controllers in HttpApi.Host project.

    https://docs.abp.io/en/commercial/latest/startup-templates/application/solution-structure#tiered-structure https://github.com/spospisil/ABPSampleServiceError/blob/0030129afd2120f96cee177503836bd8274da5c3/aspnet-core/src/StructureWeb.HttpApi.Host/StructureWebHttpApiHostModule.cs#L113

  • User Avatar
    0
    Spospisil created

    What are you suggesting I need to do in order to not need a controller to call an application service method? Are you suggesting I remove the conventionalcontrollers.Create line of code? Again, this was a out of the box solution generated by ABP Suite and I did not add this line of code myself.

    • My question, still, is how do I get javascript to call the methods on my application services WITHOUT creating a controller as the ABP documentation says I can do? If you could update the sample I have on github that shows how that is accomplished it would be much appreciated.
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You are using the tiered project, I suggest you create the controller manually. https://github.com/spospisil/ABPSampleServiceError/pull/1

  • User Avatar
    0
    Spospisil created

    Hi,

    As highlighted below, the ABP Framework documentation does not not exclude a tiered solution from this framework feature. Could you please updated your documentation accordingly so that other customers do not waste their time exploring how to do this as the documentation does not indicate that this only works for a non tiered solution?

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    We will keep improving the documentation. Thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19