如何让用户组织在java中使用Web服务客户端?

时间:2017-04-13 09:12:11

标签: java web-services liferay

  

我的代码

     

我一直在尝试获得liferay用户所拥有的组织,但是无法使用userId获取用户组织。我得到Axis故障,网址工作正常。

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)

1 个答案:

答案 0 :(得分:0)

似乎是网址

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

。首先在您的浏览器中尝试该网址。