質問

I try to add new user through WSO2 IS API, but the most recent example of use is:
WSO2 Identity Server managing users and roles through API

It works, but when I try to execute method for adding new user it breaks.

Is there more actual examples anywhere?

There is my method:

public void addUser()  throws Exception{
    String serviceEndPoint;
    UserAdminStub adminStub;

    serviceEndPoint = serverUrl + "UserAdmin";
    adminStub = new UserAdminStub(configContext, serviceEndPoint);
    ServiceClient client = adminStub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);
    option.setProperty(HTTPConstants.COOKIE_STRING, authCookie);

    Map<String, String> claims = new HashMap<String, String>();
    ClaimValue[] claimValues = new ClaimValue[2];
    ClaimValue claimValue1 = new ClaimValue();
    claimValue1.setClaimURI("http://wso2.org/claims/givenname");
    claimValue1.setValue("John");
    claimValues[0] = claimValue1;

    adminStub.addUser("sso", "sso123", null, claimValues, "default");
}

There is stack trace:

org.apache.axis2.AxisFault: unknown
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.RobustOutOnlyAxisOperation$RobustOutOnlyOperationClient.handleResponse(RobustOutOnlyAxisOperation.java:91)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.wso2.carbon.user.mgt.stub.UserAdminStub.addUser(UserAdminStub.java:1298)
at org.wso2.carbon.user.mgt.sample.UserAdminClient.addUser(UserAdminClient.java:125)
at org.wso2.carbon.user.mgt.sample.SampleUserRoleMgtClient.main(SampleUserRoleMgtClient.java:111)

And there is log from IS server:

java.lang.NullPointerException
    at org.wso2.carbon.user.mgt.UserRealmProxy.addUser(UserRealmProxy.java:255)
    at org.wso2.carbon.user.mgt.UserAdmin.addUser(UserAdmin.java:107)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
役に立ちましたか?

解決

So, I found the most recent sample in IS source code, tried it and it works =)

http://svn.wso2.org/repos/wso2/carbon/platform/tags/4.0.5/products/is/4.0.0/modules/samples/

他のヒント

Seems like your UseradminStub seems not authenticated You do it as below.

 userAdminStub = new UserAdminStub(endPoint);
 AuthenticateStub.authenticateStub(sessionCookie, userAdminStub);

Thank You, Dharshana.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top