Rest API Service method not recognised

Hello,
I have created some restapi service and methods which are working fine till 3-4 days back but suddenly the method names are not being recognised and giving following error
My service call from postman is this:

http://localhost:8080/rest/services/bpsService/sitePostsCount?projectID=323b052a-2d39-8bfa-bbcf-4f1891b8b76a

The error is as follows;

{
    "error": "Service method not found",
    "details": "bpsService.sitePostsCount(projectID)"
}

The rest-service.xml file is as follows;

<?xml version="1.0" encoding="UTF-8"?>

<services xmlns="http://jmix.io/schema/rest/services">
    <service name="bpsService">
        <method name="sitePostsCount">
            <param name="projectID"/>
        </method>
    </service>
    <service name="bpsService">
        <method name="addInspectionItemsFromGroup">
            <param name="inspectionID"/>
            <param name="tGroupID"/>
        </method>
    </service>
    <service name="bpsService">
        <method name="addTestParametersFromGroup">
            <param name="testSampleID"/>
            <param name="testMaterialID"/>
        </method>
    </service>
</services>

The implementation is as follows;

@Service("bpsService")
public class bpsService {
    @Autowired
    private Metadata metadata;
    @Autowired
    private DataManager dataManager;

    public Integer sitePostsCount (UUID projectID){
        List<SiteActivity> listSA = dataManager.load(SiteActivity.class)
                .query("select e from SiteActivity e where e.site.project.id = :projectID")
                .parameter("projectID", projectID)
                .list();
        Integer spCount = listSA.size();
        return spCount;
    }
   // some other methods
}

The application.properties file have this line

jmix.rest.services-config = rest-services.xml

Please guide.
Thanks

Sometimes it also gives following error
No bean named 'bpsService' available

Is your rest-services.xml located in the root of src/main/resources folder?

Thanks for replying. Yes it is located n the root of src/main/resources folder.

After trying this and that, i found that if there is only one method in rest-services.xml, it works. With multiple methods, it gives error. How can i resolve this.

I think that the correct may be:

<services xmlns="http://jmix.io/schema/rest/services">
    <service name="bpsService">
        <method name="sitePostsCount">
            <param name="projectID"/>
        </method>
        <method name="addInspectionItemsFromGroup">
            <param name="inspectionID"/>
            <param name="tGroupID"/>
        </method>
        <method name="addTestParametersFromGroup">
            <param name="testSampleID"/>
            <param name="testMaterialID"/>
        </method>
    </service>
</services>

Thanks for reply. This is logical and i have tried this. Same results, if there is only one method it runs, if methods are more than one, it fails.

The following setup works for me:

@Service("app_MyService")
public class MyService {

    public String echo1(String input) {
        return input;
    }

    public String echo2(String input) {
        return input;
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<services xmlns="http://jmix.io/schema/rest/services">
    <service name="app_MyService">
        <method name="echo1">
            <param name="input"/>
        </method>
        <method name="echo2">
            <param name="input"/>
        </method>
    </service>
</services>

Please provide a test project where your problem is reproduced.

Thanks. But at my side only one method in rest-service.xml is working. I have switched to custom controller method for business logic and this is working fine. Thank again for providing support.

Hi,

In some cases it is required to define parameter type, e.g. when there are multiple methods with the same name but with different set of arguments:

<method name="overloadedMethod">
   <param name="stringParam" type="java.lang.String"/>
</method>