如何从使用 Java 中的 Web 服务客户端获取用户组织



我的代码

我一直在尝试获取Liferay用户拥有的组织,但是无法使用userId获取用户组织。我得到安讯士错误,网址工作正常。

public class WStest1 {
    public static void main(String[] args) {
        System.out.println("Inside the client program!!");
        try {
            OrganizationServiceSoapServiceLocator locator = new OrganizationServiceSoapServiceLocator();
            OrganizationServiceSoap soap = locator
                    .getPortal_OrganizationService(_getURL("Portal_OrganizationService"));
            OrganizationSoap[] organizations = soap
                    .getUserOrganizations(20198l);
            for (int i = 0; i < organizations.length; i++) {
                OrganizationSoap organization = organizations[i];
                System.out.println(organization.getName());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private static URL _getURL(String serviceName) throws Exception {
        String remoteUser = "20198";
        String password = "test";
        String url = "http://" + remoteUser + ":" + password    + "@localhost:8080/api/secure/axis/" + serviceName;
        return new URL(url);
    }
}

我得到的错误是这样的。

AxisFault
 faultCode: {http://xml.apache.org/axis/}HTTP
 faultSubcode: 
 faultString: (404)Not Found
 faultActor: 
 faultNode: 
 faultDetail: 
    {}:return code:  404
(404)Not Found
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.liferay.portal.service.http.Portal_OrganizationServiceSoapBindingStub.getUserOrganizations(Portal_OrganizationServiceSoapBindingStub.java:1156)
    at com.mywebservices.WStest1.main(WStest1.java:22)

似乎网址

http://20198:test@localhost:8080/api/secure/axis/Portal_OrganizationService

未找到。首先尝试将该网址输入浏览器。

相关内容

  • 没有找到相关文章

最新更新