2 Replies Latest reply: Jul 23, 2010 6:48 PM by 807573 RSS

    Sun Role Manager API usage challenge

    807573
      Hi

      Currently Sun Role Manager exposes its API through four web service URLs. Now the challenge that I am facing is when I am trying to integrate it with a extarnal custom application through API.
      On applying wsimport for WSDL2JAVA following JAX-WS a ObjectFactory class is generated inside each package which is different for each of the service URLs. If a application want to use more than one service options say UserService and RoleService then that class is creating a conflict and thus restricting the external application from multiple service url usage. Please suggest.
        • 1. Re: Sun Role Manager API usage challenge
          807573
          Avikbasak,

          I also generated java code using JAX-WS.But when I try to invoke Business Service for getParentBusinessService I got the following error.
          Ex java.lang.IllegalStateException: Service class is not an interface. Please use an interface specify or specify one via a @WebService annotation. If I use the interface I get this error

          xception in thread "main" java.lang.NoSuchMethodError: org.codehaus.xfire.security.wss4j.WSS4JOutHandler.getString(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
          at org.codehaus.xfire.security.wss4j.WSS4JOutHandler.invoke(WSS4JOutHandler.java:74)
          at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
          at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
          at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
          at org.codehaus.xfire.client.Client.invoke(Client.java:336)
          at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
          at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
          at $Proxy12.assignUserToRole(Unknown Source)
          at com.MinsuRoleUserDate.main(MinsuRoleUserDate.java:179)
          Java Result: 1

          Any suggestions would be of great help

          Thanks
          • 2. Re: Sun Role Manager API usage challenge
            807573
            Hi,
            I have used Netbeans 6.8 to create a Java Application and created a webservice client using the netbeans wizard.
            The errors you are seeing are due to the missing authentication headers needed when making a webservices call.

            Below is an example to add autentication SOAP headers to prevent the auth errors:
            package oiaclient;
            
            import java.util.List;
            
            import com.sun.xml.ws.api.message.Header;
            import com.sun.xml.ws.api.message.Headers;
            import com.sun.xml.ws.developer.WSBindingProvider;
            import javax.xml.namespace.QName;
            import javax.xml.soap.SOAPElement;
            import javax.xml.soap.SOAPFactory;
            
            /**
             *
             * @author ramak
             */
            public class Main {
            
                public static void main(String[] args) {
            
                    try {
                        oiaclient.IdentityAuditService service = new oiaclient.IdentityAuditService();
                        oiaclient.IdentityAuditServicePortType port = service.getIdentityAuditServiceHttpPort();
            
                        SOAPFactory soapFactory = SOAPFactory.newInstance();
                        String SECURITY_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
                        QName securityQName = new QName(SECURITY_NAMESPACE, "Security");
                        SOAPElement security = soapFactory.createElement(securityQName);
                        QName usernameTokenQName = new QName(SECURITY_NAMESPACE, "UsernameToken");
                        SOAPElement usernameToken = soapFactory.createElement(usernameTokenQName);
                        QName usernameQName = new QName(SECURITY_NAMESPACE, "Username");
                        SOAPElement username = soapFactory.createElement(usernameQName);
                        username.addTextNode("rbacxadmin");
                        QName passwordQName = new QName(SECURITY_NAMESPACE, "Password");
                        SOAPElement password = soapFactory.createElement(passwordQName);
                        password.addTextNode("password");
                        usernameToken.addChildElement(username);
                        usernameToken.addChildElement(password);
                        security.addChildElement(usernameToken);
                        Header header = Headers.create(security);
            
                        ((WSBindingProvider) port).setOutboundHeaders(header);
            
                        String result = port.getVersion();
                        System.out.println("Version = " + result);
                        printLines();
            
                        ArrayOfAuditExceptionVO vo = port.getAllOpenAuditExceptions();
                        List<AuditExceptionVO> violations = vo.getAuditExceptionVO();
                        if (violations != null) {
                            System.out.println("Results of Call : getAllOpenAuditExceptions");
                            for (AuditExceptionVO violation : violations) {
                                System.out.println("Violation ID : " + violation.getId().getValue());
                                System.out.println("Violation Name : " + violation.getName().getValue());
                            }
                        }
                        printLines();
            
                        ObjectFactory of = new ObjectFactory();
                        UserVO uVO = of.createUserVO();
                        uVO.setUsername(of.createUserVOUsername("ab20082"));
            
                        AccountVO aVO = of.createAccountVO();
                        aVO.setName(of.createAccountVOName("LDAP"));
            
                        ArrayOfAccountVO aaVO = of.createArrayOfAccountVO();
                        aaVO.getAccountVO().add(aVO);
            
                        vo = port.checkForAuditExceptions(uVO, aaVO, null);
                        violations = vo.getAuditExceptionVO();
                        if (violations != null) {
                            System.out.println("Results of Call : checkForAuditExceptions");
                            for (AuditExceptionVO violation : violations) {
                                System.out.println("Violation ID : " + violation.getId().getValue());
                                System.out.println("Violation Name : " + violation.getName().getValue());
                            }
                        }
                        printLines();
            
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            
                public static void printLines() {
                        System.out.println("");
                        System.out.println("--------------------------------------------");
                        System.out.println("");
                }
            }