Created
October 21, 2015 06:53
-
-
Save lahirue/54d0af566fe2fca34897 to your computer and use it in GitHub Desktop.
WSO2 Carbon Component UI Service Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.wso2.carbon.testService.ui; | |
import java.rmi.RemoteException; | |
import org.apache.axis2.client.Options; | |
import org.apache.axis2.client.ServiceClient; | |
import org.apache.axis2.context.ConfigurationContext; | |
import org.wso2.carbon.testService.ui.types.data.User; | |
public class UserClient { | |
MyTestServiceStub stub; | |
public UserClient(ConfigurationContext configCtx, String backendServerURL, String cookie) throws Exception { | |
String serviceURL = backendServerURL + "MyTestService"; | |
stub = new MyTestServiceStub(configCtx, serviceURL); | |
ServiceClient client = stub._getServiceClient(); | |
Options options = client.getOptions(); | |
options.setManageSession(true); | |
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); | |
} | |
public User addUser(String anUser, int anAge) throws Exception { | |
try { | |
return stub.addUser(anUser, anAge); | |
} catch (RemoteException e) { | |
e.printStackTrace(); | |
String msg = "Cannot add the User" + " . Backend service may be unvailable"; | |
throw new Exception(msg, e); | |
} | |
} | |
public User[] displayUsers() throws Exception { | |
try { | |
return stub.displayUsers(); | |
} catch (RemoteException e) { | |
e.printStackTrace(); | |
String msg = "Cannot display the Users" + " . Backend service may be unvailable"; | |
throw new Exception(msg, e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment