0

我正在尝试使用org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient创建注册表对象。目标是查找具有特定属性的服务。在尝试运行以下代码时:

WSRegistryServiceClient registry = new WSRegistryServiceClient(serverURL, "admin", "admin", configContext);
    org.wso2.carbon.governance.api.services.ServiceManager serviceManager = new org.wso2.carbon.governance.api.services.ServiceManager(registry); 
        Service[] services = serviceManager.findServices(new ServiceFilter() 
        {
                public boolean matches(Service service) throws GovernanceException {
                        String attributeVal = service.getAttribute("owner_name");
                        return (attributeVal != null && attributeVal.equals("someName"));
                    }
                });

我得到类播异常

      java.lang.ClassCastException: org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient cannot be cast to org.wso2.carbon.registry.core.session.UserRegistry exception
at org.wso2.carbon.governance.api.util.GovernanceUtils.retrieveGovernanceArtifactByPath(GovernanceUtils.java:819)
    at org.wso2.carbon.governance.api.common.GovernanceArtifactManager.getAllGovernanceArtifacts(GovernanceArtifactManager.java:663)
    at org.wso2.carbon.governance.api.services.ServiceManager.getAllServices(ServiceManager.java:213)
    at org.wso2.carbon.governance.api.services.ServiceManager.findServices(ServiceManager.java:186)

WSO2 的文档演示了使用 WSRegistryServiceClient 添加服务,但我找不到演示搜索服务的示例。我使用同一个客户端搜索服务,但它引发了上述异常。搜索服务的方式应该是什么?

另外,有没有办法从 WSRegistryServiceClient 创建 UserRegistry 对象,或者有不同的 api 来创建 UserRegistry ?

4

0 回答 0