Jump to content

Create/Update contact using WebServices


Recommended Posts

Hi,

wish to know if it´s possible to create/update contact records using the SDM webservices.

The problem is at my organization all relevant contact data resides at an Oracle DB. Windows AD is used only to authentication.

I managed to create all contacts using pdm_load, but it's not practicall to do it as a batch.

So, can this be accomplished with WebServices ?

Regards

Link to post
Share on other sites

here's a java class that should show even a beginner programmer how to manage contacts via webservices... this was a hack/bash from my webservice learning experience... Please note, this code can not be directly copy/pasted and work.. Due to the Copyright info at the top of CA's samples (which was the origination point of my learning), i removed some components to ensure respect for the copyright

by far the best place to get information on webservices is the technical reference for your SDM version.

import org.apache.axis.AxisFault;

import java.io.*;
import java.util.Date;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.InputSource;

import com.ca.www.UnicenterServicePlus.ServiceDesk.*;

public class contact_doquery_list
{
    public contact_doquery_list()
    {
        // The endpoint for the R11 web service
    //the POC URL
        String endpoint = "http://sdwdpoc003:8080/axis/services/USD_R11_WebService?wsdl";

        //  Assume username and password are both "ServiceDesk"
        String username = "ServiceDesk";
        String password = "ServiceDesk";


//here you would login:
            int sid = usd.login(username, password);
    
            if (sid <= 0) // valid sid is greater than 0
            {
                System.out.println("login failed!");
                return;
            }

            System.out.println("login() succeeded. SID: " + sid + "\n");




            ArrayOfString userArr = new ArrayOfString();
            userArr.setString(new String[]{"first_name", "last_name", "access_type.sym",
                              "organization", "organization.name", "admin_org.name", "group_list.length" });



        System.out.println ("contact where userid=XXXX");
        //String ManagertestHandle = usd.getHandleForUserid(sid, "ahdfha"); //this method works - but forces program to exit if it fails
        String ManagertestHandle = getHandleForLocSite(sid, usd, "cnt", "userid='XXXX'"); //this will return null if user is not found
        System.out.println ("handle=" + ManagertestHandle);

        //locations will be in the form of "absPrimLocation / location name / General"
        //users should be tied to the "General" location for their absPrimLocation
        System.out.println ("locations where name LIKE '1002873 % / General'");
        String LoctestHandle = getHandleForLocSite(sid, usd, "loc", "name LIKE '1002873 % / General'");
        System.out.println ("handle=" + LoctestHandle);

        //users dont get associated to sites, this example is here for reference
        System.out.println ("sites where name LIKE BHO%");
        String SitetestHandle = getHandleForLocSite(sid, usd, "site", "name LIKE 'BHO%'");
        System.out.println ("handle=" + SitetestHandle);

        //all new contacts/users will have contact type of "employee"
        //this attribute will only be set on creation of contact record by IDM - this attribute will never be updated by IDM
        System.out.println ("contact types where name=employee");
        String ContactTypetestHandle = getHandleForType(sid, usd, "ctp", "sym='employee'");
        System.out.println ("handle=" + ContactTypetestHandle);

        //all new contacts/users will have access type (as well as contact type) of "employee"
        //this attribute will only be set on creation of contact record by IDM - this attribute will never be updated by IDM
        System.out.println ("access types where name=employee");
        String AccesstypetestHandle = getHandleForType(sid, usd, "acctyp", "sym='employee'");
        System.out.println ("handle=" + AccesstypetestHandle);

        //this attribute wont be set by IDM - here for reference
        System.out.println ("timezone where sym='Mountain Time'");
        String TZtestHandle = getHandleForType(sid, usd, "tz", "sym='Mountain Time'");
        System.out.println ("handle=" + TZtestHandle);

        //this absJobCode (which is a number) will map to a "position" in CA SDM
        //positions in CA SDM will have a symbol in the form of "absJobCode / positionName"
        //i.e.
        //000033 / Supply Chain Analyst II
        System.out.println ("position where sym LIKE '000033 / %'");
        String PositiontestHandle = getHandleForType(sid, usd, "position", "sym LIKE '000033 / %'");
        System.out.println ("handle=" + PositiontestHandle);

        
        System.out.println ("create a contact record...");
        String s = "test" + new Date(); // just to get a unique string to use as userID and name of this contact
        //we set delete_flag to 0 (zero) to make this an active contact record, set it to 1 to make this an inactive contact
        String[] newAttrs = {"delete_flag", "0", "first_name",s, "last_name", "userLast", "middle_name", "userMiddle", "userid", s, "email_address", "email@domain.com", "access_type", AccesstypetestHandle, "supervisor_contact_uuid", ManagertestHandle, "contact_num", "userEmployeeNumber", "location", LoctestHandle, "position", PositiontestHandle, "type", ContactTypetestHandle, "phone_number", "1234567890", };
        ArrayOfString newAttr = new ArrayOfString();
        newAttr.setString(newAttrs);
            String[] retAttrs = {"first_name", "last_name", "access_type.sym"};
        ArrayOfString retAttr = new ArrayOfString();
        retAttr.setString(retAttrs);

        javax.xml.rpc.holders.StringHolder createObjectResult = new javax.xml.rpc.holders.StringHolder("");
        javax.xml.rpc.holders.StringHolder newHandle = new javax.xml.rpc.holders.StringHolder("");
        usd.createObject(sid, "cnt", newAttr, retAttr, createObjectResult, newHandle);
        System.out.println ("createObjectResult:");
        System.out.println (createObjectResult.value);
        
        System.out.println ("");
        System.out.println ("newHandle:");
        System.out.println (newHandle.value);


        usd.logout(sid);
        }
        catch (AxisFault af)
        {              
            System.out.println("...AxisFault...");
            System.out.println(af.toString());
        }    
        catch (Exception ex)
        {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }
    }

    private String getHandleForType(int sid, USD_WebServiceSoap usd, String type, String query) {
        String[] myArray = {"sym"};
        String results = null;
        try {
            results = usd.doSelect(sid, type, query, -1, new ArrayOfString(myArray));
        } catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        //System.out.println ("results=" + results);
        String handle = getHandleElement (results);
        //System.out.println ("handle = " + handle);

        return handle;
        
    }
    private String getHandleForLocSite(int sid, USD_WebServiceSoap usd, String type, String query) {
        String[] myArray = {"id"};
        String results = null;
        try {
            results = usd.doSelect(sid, type, query, -1, new ArrayOfString(myArray));
        } catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        //System.out.println ("results=" + results);
        String handle = getHandleElement (results);
        //System.out.println ("handle = " + handle);

        return handle;
        
    }

    private void queryList(int sid, USD_WebServiceSoap usd, String type, String query) {
        try {
            ListResult doQueryResult = new ListResult();
            //doQueryResult = usd.doQuery(sid, "cr", "active = 1");
            doQueryResult = usd.doQuery(sid, type, "userid LIKE '%" + query + "%'");
            int listHandle = doQueryResult.getListHandle();
            int listLength = doQueryResult.getListLength();

            ArrayOfString attrNames = new ArrayOfString();
            attrNames.setString(new String[]{"userid", "last_name", "first_name", "type", "type.sym", "organization", "organization.name" });

            int startIndex = 0;
            int endIndex;
            boolean doMore = false;
            if (listLength > 0) doMore = true;

            while ( doMore ) {
                if (listLength > (startIndex + 10))
                    endIndex = startIndex + 9;
                else {
                    endIndex = listLength - 1;
                    doMore = false;
                }

                System.out.println("Output of startIndex: " + startIndex + " to endIndex: " + endIndex);
                String lResult = usd.getListValues(sid, listHandle, startIndex, endIndex, attrNames);
                //System.out.println(lResult);
                display_attribute_values(lResult);
                System.out.println("");

                if ( doMore )
                startIndex += 10;
            }

        }
        catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }
    }


    private String getHandleElement (String result) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(new StringReader(result)));
            Element root = doc.getDocumentElement();
            NodeList attributesList = root.getElementsByTagName("Handle");
            String outString = "";
            if (attributesList.getLength() > 0) {
                System.out.println ("found 1 or more \"Handle\" elements...");
                Element attributesElement = (Element) attributesList.item(0);
                Text attrValueText = (Text) attributesElement.getFirstChild();
                String attrValueString = "";
                if (attrValueText != null)
                    attrValueString = attrValueText.getNodeValue();

                return attrValueString;
            }
            else {
                System.out.println ("found 0 \"Handle\" elements...");
            }
        } catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        return null;

    }
        private void display_attribute_values2 (String result) {
        try
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(new StringReader(result)));
            Element root = doc.getDocumentElement();
            //NodeList udsObjectList = root.getElementsByTagName("UDSObject");
            //int udsObjectListLength = udsObjectList.getLength();
        //System.out.println ("udsObjectListLength = " + udsObjectListLength);

            //Element udsObjectElement = (Element) root.getElementByTagName("UDSObject");

            //NodeList attributesList = udsObjectElement.getElementsByTagName("Attributes");
            NodeList attributesList = root.getElementsByTagName("Attributes");
        String outString = "";
                if (attributesList.getLength() > 0)
                {
                    Element attributesElement = (Element) attributesList.item(0);
                    NodeList attributeList = attributesElement.getElementsByTagName("Attribute");

                    for (int i = 0; i < attributeList.getLength(); i++)
                    {
                        Element attributeElement = (Element) attributeList.item(i);
                        NodeList attrNameList = attributeElement.getElementsByTagName("AttrName");

                        Element attrNameElement = (Element) attrNameList.item(0);
                        Text attrNameText = (Text) attrNameElement.getFirstChild();
                        String attrNameString = attrNameText.getNodeValue();

                        // Each Attribute element will have one AttrValue, though it may be null
                        NodeList attrValueList = attributeElement.getElementsByTagName("AttrValue");
                        Element attrValueElement = (Element) attrValueList.item(0);
                        Text attrValueText = (Text) attrValueElement.getFirstChild();
            String attrValueString = "";
                        if (attrValueText != null)
                            attrValueString = attrValueText.getNodeValue();
            if (i > 0)
                            outString += ", ";
                        outString += attrNameString + ": " + attrValueString;
                    }
                    System.out.println(outString);
                }
            
    }
        catch (Exception ex)
        {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }
    }

    private void display_attribute_values (String result)
    {
        try
        {

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(new StringReader(result)));
            Element root = doc.getDocumentElement();
            NodeList udsObjectList = root.getElementsByTagName("UDSObject");
            int udsObjectListLength = udsObjectList.getLength();
        System.out.println ("udsObjectListLength = " + udsObjectListLength);

             for (int j = 0; j < udsObjectListLength; j++)
             {
                Element udsObjectElement = (Element) udsObjectList.item(j);

                NodeList attributesList = udsObjectElement.getElementsByTagName("Attributes");
        String outString = "";
                if (attributesList.getLength() > 0)
                {
                    Element attributesElement = (Element) attributesList.item(0);
                    NodeList attributeList = attributesElement.getElementsByTagName("Attribute");

                    for (int i = 0; i < attributeList.getLength(); i++)
                    {
                        Element attributeElement = (Element) attributeList.item(i);
                        NodeList attrNameList = attributeElement.getElementsByTagName("AttrName");

                        Element attrNameElement = (Element) attrNameList.item(0);
                        Text attrNameText = (Text) attrNameElement.getFirstChild();
                        String attrNameString = attrNameText.getNodeValue();

                        // Each Attribute element will have one AttrValue, though it may be null
                        NodeList attrValueList = attributeElement.getElementsByTagName("AttrValue");
                        Element attrValueElement = (Element) attrValueList.item(0);
                        Text attrValueText = (Text) attrValueElement.getFirstChild();
            String attrValueString = "";
                        if (attrValueText != null)
                            attrValueString = attrValueText.getNodeValue();
            if (i > 0)
                            outString += ", ";
                        outString += attrNameString + ": " + attrValueString;
                    }
                    System.out.println(outString);
                }
            }
        }
        catch (Exception ex)
        {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        
    }

    static public void main(String[] argv)
    {
        new contact_doquery_list();
    }
}

I guess i should mention, that this is just to show you how to work with contact objects and webservices via CA SDM 12.5+, you'll need (a lot of?) additional work if you want an enterprise solution that manages your contacts in SDM off your enterprise ldap/AD/etc...

Edited by TorreyJones
Link to post
Share on other sites
  • 3 years later...

Is it possible to achieve this using C# ?

here's a java class that should show even a beginner programmer how to manage contacts via webservices... this was a hack/bash from my webservice learning experience... Please note, this code can not be directly copy/pasted and work.. Due to the Copyright info at the top of CA's samples (which was the origination point of my learning), i removed some components to ensure respect for the copyright

by far the best place to get information on webservices is the technical reference for your SDM version.

import org.apache.axis.AxisFault;

import java.io.*;
import java.util.Date;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.InputSource;

import com.ca.www.UnicenterServicePlus.ServiceDesk.*;

public class contact_doquery_list
{
    public contact_doquery_list()
    {
        // The endpoint for the R11 web service
    //the POC URL
        String endpoint = "http://sdwdpoc003:8080/axis/services/USD_R11_WebService?wsdl";

        //  Assume username and password are both "ServiceDesk"
        String username = "ServiceDesk";
        String password = "ServiceDesk";


//here you would login:
            int sid = usd.login(username, password);
    
            if (sid <= 0) // valid sid is greater than 0
            {
                System.out.println("login failed!");
                return;
            }

            System.out.println("login() succeeded. SID: " + sid + "\n");




            ArrayOfString userArr = new ArrayOfString();
            userArr.setString(new String[]{"first_name", "last_name", "access_type.sym",
                              "organization", "organization.name", "admin_org.name", "group_list.length" });



        System.out.println ("contact where userid=XXXX");
        //String ManagertestHandle = usd.getHandleForUserid(sid, "ahdfha"); //this method works - but forces program to exit if it fails
        String ManagertestHandle = getHandleForLocSite(sid, usd, "cnt", "userid='XXXX'"); //this will return null if user is not found
        System.out.println ("handle=" + ManagertestHandle);

        //locations will be in the form of "absPrimLocation / location name / General"
        //users should be tied to the "General" location for their absPrimLocation
        System.out.println ("locations where name LIKE '1002873 % / General'");
        String LoctestHandle = getHandleForLocSite(sid, usd, "loc", "name LIKE '1002873 % / General'");
        System.out.println ("handle=" + LoctestHandle);

        //users dont get associated to sites, this example is here for reference
        System.out.println ("sites where name LIKE BHO%");
        String SitetestHandle = getHandleForLocSite(sid, usd, "site", "name LIKE 'BHO%'");
        System.out.println ("handle=" + SitetestHandle);

        //all new contacts/users will have contact type of "employee"
        //this attribute will only be set on creation of contact record by IDM - this attribute will never be updated by IDM
        System.out.println ("contact types where name=employee");
        String ContactTypetestHandle = getHandleForType(sid, usd, "ctp", "sym='employee'");
        System.out.println ("handle=" + ContactTypetestHandle);

        //all new contacts/users will have access type (as well as contact type) of "employee"
        //this attribute will only be set on creation of contact record by IDM - this attribute will never be updated by IDM
        System.out.println ("access types where name=employee");
        String AccesstypetestHandle = getHandleForType(sid, usd, "acctyp", "sym='employee'");
        System.out.println ("handle=" + AccesstypetestHandle);

        //this attribute wont be set by IDM - here for reference
        System.out.println ("timezone where sym='Mountain Time'");
        String TZtestHandle = getHandleForType(sid, usd, "tz", "sym='Mountain Time'");
        System.out.println ("handle=" + TZtestHandle);

        //this absJobCode (which is a number) will map to a "position" in CA SDM
        //positions in CA SDM will have a symbol in the form of "absJobCode / positionName"
        //i.e.
        //000033 / Supply Chain Analyst II
        System.out.println ("position where sym LIKE '000033 / %'");
        String PositiontestHandle = getHandleForType(sid, usd, "position", "sym LIKE '000033 / %'");
        System.out.println ("handle=" + PositiontestHandle);

        
        System.out.println ("create a contact record...");
        String s = "test" + new Date(); // just to get a unique string to use as userID and name of this contact
        //we set delete_flag to 0 (zero) to make this an active contact record, set it to 1 to make this an inactive contact
        String[] newAttrs = {"delete_flag", "0", "first_name",s, "last_name", "userLast", "middle_name", "userMiddle", "userid", s, "email_address", "email@domain.com", "access_type", AccesstypetestHandle, "supervisor_contact_uuid", ManagertestHandle, "contact_num", "userEmployeeNumber", "location", LoctestHandle, "position", PositiontestHandle, "type", ContactTypetestHandle, "phone_number", "1234567890", };
        ArrayOfString newAttr = new ArrayOfString();
        newAttr.setString(newAttrs);
            String[] retAttrs = {"first_name", "last_name", "access_type.sym"};
        ArrayOfString retAttr = new ArrayOfString();
        retAttr.setString(retAttrs);

        javax.xml.rpc.holders.StringHolder createObjectResult = new javax.xml.rpc.holders.StringHolder("");
        javax.xml.rpc.holders.StringHolder newHandle = new javax.xml.rpc.holders.StringHolder("");
        usd.createObject(sid, "cnt", newAttr, retAttr, createObjectResult, newHandle);
        System.out.println ("createObjectResult:");
        System.out.println (createObjectResult.value);
        
        System.out.println ("");
        System.out.println ("newHandle:");
        System.out.println (newHandle.value);


        usd.logout(sid);
        }
        catch (AxisFault af)
        {              
            System.out.println("...AxisFault...");
            System.out.println(af.toString());
        }    
        catch (Exception ex)
        {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }
    }

    private String getHandleForType(int sid, USD_WebServiceSoap usd, String type, String query) {
        String[] myArray = {"sym"};
        String results = null;
        try {
            results = usd.doSelect(sid, type, query, -1, new ArrayOfString(myArray));
        } catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        //System.out.println ("results=" + results);
        String handle = getHandleElement (results);
        //System.out.println ("handle = " + handle);

        return handle;
        
    }
    private String getHandleForLocSite(int sid, USD_WebServiceSoap usd, String type, String query) {
        String[] myArray = {"id"};
        String results = null;
        try {
            results = usd.doSelect(sid, type, query, -1, new ArrayOfString(myArray));
        } catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        //System.out.println ("results=" + results);
        String handle = getHandleElement (results);
        //System.out.println ("handle = " + handle);

        return handle;
        
    }

    private void queryList(int sid, USD_WebServiceSoap usd, String type, String query) {
        try {
            ListResult doQueryResult = new ListResult();
            //doQueryResult = usd.doQuery(sid, "cr", "active = 1");
            doQueryResult = usd.doQuery(sid, type, "userid LIKE '%" + query + "%'");
            int listHandle = doQueryResult.getListHandle();
            int listLength = doQueryResult.getListLength();

            ArrayOfString attrNames = new ArrayOfString();
            attrNames.setString(new String[]{"userid", "last_name", "first_name", "type", "type.sym", "organization", "organization.name" });

            int startIndex = 0;
            int endIndex;
            boolean doMore = false;
            if (listLength > 0) doMore = true;

            while ( doMore ) {
                if (listLength > (startIndex + 10))
                    endIndex = startIndex + 9;
                else {
                    endIndex = listLength - 1;
                    doMore = false;
                }

                System.out.println("Output of startIndex: " + startIndex + " to endIndex: " + endIndex);
                String lResult = usd.getListValues(sid, listHandle, startIndex, endIndex, attrNames);
                //System.out.println(lResult);
                display_attribute_values(lResult);
                System.out.println("");

                if ( doMore )
                startIndex += 10;
            }

        }
        catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }
    }


    private String getHandleElement (String result) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(new StringReader(result)));
            Element root = doc.getDocumentElement();
            NodeList attributesList = root.getElementsByTagName("Handle");
            String outString = "";
            if (attributesList.getLength() > 0) {
                System.out.println ("found 1 or more \"Handle\" elements...");
                Element attributesElement = (Element) attributesList.item(0);
                Text attrValueText = (Text) attributesElement.getFirstChild();
                String attrValueString = "";
                if (attrValueText != null)
                    attrValueString = attrValueText.getNodeValue();

                return attrValueString;
            }
            else {
                System.out.println ("found 0 \"Handle\" elements...");
            }
        } catch (Exception ex) {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        return null;

    }
        private void display_attribute_values2 (String result) {
        try
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(new StringReader(result)));
            Element root = doc.getDocumentElement();
            //NodeList udsObjectList = root.getElementsByTagName("UDSObject");
            //int udsObjectListLength = udsObjectList.getLength();
        //System.out.println ("udsObjectListLength = " + udsObjectListLength);

            //Element udsObjectElement = (Element) root.getElementByTagName("UDSObject");

            //NodeList attributesList = udsObjectElement.getElementsByTagName("Attributes");
            NodeList attributesList = root.getElementsByTagName("Attributes");
        String outString = "";
                if (attributesList.getLength() > 0)
                {
                    Element attributesElement = (Element) attributesList.item(0);
                    NodeList attributeList = attributesElement.getElementsByTagName("Attribute");

                    for (int i = 0; i < attributeList.getLength(); i++)
                    {
                        Element attributeElement = (Element) attributeList.item(i);
                        NodeList attrNameList = attributeElement.getElementsByTagName("AttrName");

                        Element attrNameElement = (Element) attrNameList.item(0);
                        Text attrNameText = (Text) attrNameElement.getFirstChild();
                        String attrNameString = attrNameText.getNodeValue();

                        // Each Attribute element will have one AttrValue, though it may be null
                        NodeList attrValueList = attributeElement.getElementsByTagName("AttrValue");
                        Element attrValueElement = (Element) attrValueList.item(0);
                        Text attrValueText = (Text) attrValueElement.getFirstChild();
            String attrValueString = "";
                        if (attrValueText != null)
                            attrValueString = attrValueText.getNodeValue();
            if (i > 0)
                            outString += ", ";
                        outString += attrNameString + ": " + attrValueString;
                    }
                    System.out.println(outString);
                }
            
    }
        catch (Exception ex)
        {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }
    }

    private void display_attribute_values (String result)
    {
        try
        {

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(new StringReader(result)));
            Element root = doc.getDocumentElement();
            NodeList udsObjectList = root.getElementsByTagName("UDSObject");
            int udsObjectListLength = udsObjectList.getLength();
        System.out.println ("udsObjectListLength = " + udsObjectListLength);

             for (int j = 0; j < udsObjectListLength; j++)
             {
                Element udsObjectElement = (Element) udsObjectList.item(j);

                NodeList attributesList = udsObjectElement.getElementsByTagName("Attributes");
        String outString = "";
                if (attributesList.getLength() > 0)
                {
                    Element attributesElement = (Element) attributesList.item(0);
                    NodeList attributeList = attributesElement.getElementsByTagName("Attribute");

                    for (int i = 0; i < attributeList.getLength(); i++)
                    {
                        Element attributeElement = (Element) attributeList.item(i);
                        NodeList attrNameList = attributeElement.getElementsByTagName("AttrName");

                        Element attrNameElement = (Element) attrNameList.item(0);
                        Text attrNameText = (Text) attrNameElement.getFirstChild();
                        String attrNameString = attrNameText.getNodeValue();

                        // Each Attribute element will have one AttrValue, though it may be null
                        NodeList attrValueList = attributeElement.getElementsByTagName("AttrValue");
                        Element attrValueElement = (Element) attrValueList.item(0);
                        Text attrValueText = (Text) attrValueElement.getFirstChild();
            String attrValueString = "";
                        if (attrValueText != null)
                            attrValueString = attrValueText.getNodeValue();
            if (i > 0)
                            outString += ", ";
                        outString += attrNameString + ": " + attrValueString;
                    }
                    System.out.println(outString);
                }
            }
        }
        catch (Exception ex)
        {
            System.out.println("Exception occurred:" + ex.getMessage());
            ex.printStackTrace(System.out);
        }

        
    }

    static public void main(String[] argv)
    {
        new contact_doquery_list();
    }
}

I guess i should mention, that this is just to show you how to work with contact objects and webservices via CA SDM 12.5+, you'll need (a lot of?) additional work if you want an enterprise solution that manages your contacts in SDM off your enterprise ldap/AD/etc...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...