Layer7 Identity Management

Expand all | Collapse all

Executing Create User Via TEWS

Jump to Best Answer
  • 1.  Executing Create User Via TEWS

    Posted 07-19-2016 05:47 AM

    HI All,

     

    We are trying to create a user in IDM 12.6.8 using TEWS. We are trying to develop client in java using the web service java sample for wsdl that will invoke the createuser method to create a user. While running the client code, system returns error and we are clueless what is causing system to return this error.  PFB the error while running and error in server.log .

     

    tews6.wsdl.CreateUserFaultMessage: Error parsing incoming document.

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

      at java.lang.reflect.Constructor.newInstance(Unknown Source)

      at tews6.wsdl.Tews6Stub.createUser(Tews6Stub.java:10017)

      at tews6.invokefucn.CreateUser.execute(CreateUser.java:103)

      at tews6.invokefucn.CreateUser.main(CreateUser.java:33)

     

     

    2016-07-19 13:37:43,285 ERROR [ims.default] (default task-15) Could not read SOAP content

    2016-07-19 13:37:43,285 ERROR [ims.default] (default task-15) org.xml.sax.SAXException: org.xml.sax.SAXException: Premature end of file.

    org.xml.sax.SAXParseException; Premature end of file.

      at com.netegrity.ims.tews6.XmlHandler.fatalError(XmlHandler.java:142) [ims.jar:]

      at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) [xercesImpl.jar:]

      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) [xercesImpl.jar:]

      at com.netegrity.ims.tews6.ServiceServlet.doPost(ServiceServlet.java:270) [ims.jar:]



  • 2.  Re: Executing Create User Via TEWS

    Posted 07-19-2016 05:58 PM

    Did you edit the Createuser java file yourself?

    If you did, are you able to supply it here so we can see?



  • 3.  Re: Executing Create User Via TEWS

    Posted 07-20-2016 06:19 AM

    He is the complete code.

    ###########################################################

    import java.util.ArrayList;

    import java.util.List;

    import org.apache.axis2.AxisFault;

    import org.apache.axis2.transport.http.HTTPConstants;

    import org.apache.axis2.transport.http.HttpTransportProperties;

    import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;

     

     

    import tews6.wsdl.CreateUserDocument;

    import tews6.wsdl.CreateUserTaskContextDocument;

    import tews6.wsdl.ImsStatusDocument;

    import tews6.wsdl.Tews6Stub;

    import tews6.wsdl.CreateUserProfileTabDocument.CreateUserProfileTab;

    import tews6.wsdl.CreateUserSearchDocument.CreateUserSearch;

    import tews6.wsdl.CreateUserSearchDocument.CreateUserSearch.Organization;

    import tews6.wsdl.CreateUserTaskContextDocument.CreateUserTaskContext;

     

     

     

     

    public class CreateUser {

     

     

      // set this to true if you have set up a SiteMinder realm+rule to protect TEWS

      private final boolean _bIsProtectedBySiteMinder = false;

      private Tews6Stub stub = null;

     

     

      private CreateUser() throws AxisFault {

      stub = new Tews6Stub();

      }

      public static void main(String[] args) {

      try {

      CreateUser createUser = new CreateUser();

      createUser.execute();

      } catch (AxisFault e) {

      e.printStackTrace();

      } catch (Exception e) {

      e.printStackTrace();

      }

     

     

      }

     

     

      /**

      * This method contructs the soap request for Create User service and executes the service.

      * @throws Exception

      */

      public void execute() throws Exception {

      String admin_id = "superadmin";

      String admin_pwd = "password";

     

     

      if (_bIsProtectedBySiteMinder) {

      // Setting the site minder authentication details.

      HttpTransportProperties.Authenticator basicAuthenticator = new HttpTransportProperties.Authenticator();

      List<String> authSchemes = new ArrayList<String>();

      authSchemes.add(Authenticator.BASIC);

      basicAuthenticator.setAuthSchemes(authSchemes);

      basicAuthenticator.setUsername("superadmin");

      basicAuthenticator.setPassword(admin_pwd);

      stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuthenticator);

      stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, "false");

      stub._getServiceClient().getOptions().setProperty("Cookie","SMCHALLENGE=YES");

      } else {

      admin_id = "uid=SuperAdmin,ou=admin,dc=users,dc=com";

      }

     

     

      CreateUserDocument createUserDocument = CreateUserDocument.Factory.newInstance();

      tews6.wsdl.CreateUserDocument.CreateUser createUser = tews6.wsdl.CreateUserDocument.CreateUser.Factory.newInstance();

      CreateUserSearch createUserSearch = CreateUserSearch.Factory.newInstance();

     

     

      // indicate that we are creating a brand new user

      createUserSearch.setCreateNew(true);

     

      // set the org in which to create this user

      Organization organization = Organization.Factory.newInstance();

      organization.setUniqueName("ou=users,dc=users,dc=com");

      createUserSearch.setOrganization(organization);

      createUser.setCreateUserSearch(createUserSearch);

     

     

      CreateUserProfileTab createUserProfileTab = CreateUserProfileTab.Factory.newInstance();

      // Set the org via profileTab

      createUserProfileTab.setPCTORGMEMBERSHIPPCT("ou=users,dc=users,dc=com");

     

      // Set some attributes

      createUserProfileTab.setPCTUSERIDPCT("newSupplier");

      createUserProfileTab.setPCTLASTNAMEPCT("Supplier");

      createUserProfileTab.setPCTFIRSTNAMEPCT("New");

      createUserProfileTab.setPCTFULLNAMEPCT("New Supplier");

      createUserProfileTab.setDepartmentNumber("Dept Number");

      createUserProfileTab.setEmployeeNumber("Emp Number");

      createUserProfileTab.setPostalAddress("Postal address");

      createUserProfileTab.setPostalCode("Postal code");

      createUserProfileTab.setSt("street");

      createUserProfileTab.setTitle("supplier title");

      createUserProfileTab.setPCTPASSWORDPCT("aaa");

      createUserProfileTab.setBARPasswordConfirmBAR("aaa");

     

     

      createUser.setCreateUserProfileTab(createUserProfileTab);

      createUserDocument.setCreateUser(createUser);

     

     

      CreateUserTaskContextDocument createUserTaskContextDocument = CreateUserTaskContextDocument.Factory.newInstance();

      CreateUserTaskContext createUserTaskContext = createUserTaskContextDocument.addNewCreateUserTaskContext();

      createUserTaskContext.setAdminId(admin_id);

      createUserTaskContext.setAdminPassword(admin_pwd);

     

      ImsStatusDocument imsStatusDoc = stub.createUser(createUserDocument, createUserTaskContextDocument);

     

      if (imsStatusDoc != null) {

     

      // SampleUtils.checkStatus(imsStatusDoc.getImsStatus());

      String[] messages = imsStatusDoc.getImsStatus().getInfoMessageArray();

      for (int i = 0; i < messages.length; i++) {

      System.out.println(messages[i]);

      }

      } else {

      System.out.println("Not able to get Status.");

      }

      }

    }

     

    ########################################################################################################



  • 4.  Re: Executing Create User Via TEWS
    Best Answer

    Posted 07-20-2016 11:14 AM

    Vasudev- please open a support ticket and attach this server.log, your client code, export of roles.xml and so on.

    This will require some detailed analysis



  • 5.  Re: Executing Create User Via TEWS

    Posted 08-09-2017 06:11 AM

    Hi,

    Were you able to resolve the issue eventually? I have the same problem, so any input would help.

     

    Thanks,

    Debasish.



  • 6.  Re: Executing Create User Via TEWS

    Posted 08-09-2017 07:39 PM

    Hi Debasish,

     

    Vasu did raise a support ticket and the final resolution was:

     

    - commented the code under if (_bIsProtectedBySiteMinder) block and added the below line under ViewUser() constructor
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, "false");
    After doing the modification we are able to execute the TEWS call 

     

    If you are still having problems, please do raise a case and we can take a look at your code.

     

    Regards,

    Marline



  • 7.  Re: Executing Create User Via TEWS

    Posted 08-10-2017 03:06 AM

    Hi Marline,

    Thanks a lot. The solution worked..

     

    Thanks,

    Debasish.