This blog is in continuation to Part 1 where we have discussed an example and informal logic to consume Directory API.
For working and consuming Webservice api in Java, one should understand JAXB.
Java Architecture for XML Binding (JAXB) allows Java developers to map Java classes to XML representations
JAXB is different from DOM or SAX.The Java DOM and SAX parsing APIs are lower-level APIs to parse XML documents, while JAXB (Java API for XML Binding) is a higher-level API for converting XML elements and attributes to a Java object hierarchy (and vice versa).
Now coming to development of standalone NWDS project.
For initial setup part please refer these 3 comprehensive blogs by William Li are good reference :
Directory API Development - Part 1 of 3
Directory API Development - Part 2 of 3
Directory API Development - Part 3 of 3
After import of API WSDL and Generate client step, classes specific to XML Schema are generated.
We can find types and getter and setter functions for each XML element(courtesy JAXB
).
Using these elements and get set methods one can traverse all API data.
As discussed in prev blog,
ICO-create() for Sender component : Change in MessageHeaderId & InboundProcessing .
ICO-change() for Receiver Component: Change in Receivers, ReceiverInterrfaces & OutboundProcessing.
Below is code for the NWDS project fo Create ICO Class.
NWDS Project Code:
mainClass
public static void main(String[] args)
{ String csvFilePath = new String (<DataFile>); String[] bsList = readExcel(csvFilePath); CreateIntegratedConfiguration obj = new CreateIntegratedConfiguration(user,password,hostPort,bsList); obj.createICO();
}
Class
CreateIntegratedConfiguration
//Function createICO()
public void createICO()
{
IntegratedConfigurationCreateChangeIn
createIn=new IntegratedConfigurationCreateChangeIn();
createIn.setChangeListID(createChangeListId());
try{
List<RestrictedIntegratedConfiguration>
listCreateICO = createIn.getIntegratedConfiguration();
listCreateICO.addAll(readICO(queryICO()));
//Create Configuration Object
ConfigurationObjectModifyOut createOut
= port.create(createIn);
}
catch (Exception e) {
e.printStackTrace();
rejectChangeListId(createIn.getChangeListID().toString());
System.exit(0);
}
}
// Function queryICO()
public
List<MessageHeaderID> queryICO() {
IntegratedConfigurationQueryIn
queryIn = new IntegratedConfigurationQueryIn();
MessageHeaderID msgHdr = new
MessageHeaderID();
msgHdr.setSenderComponentID(getSourceBS());
queryIn.setIntegratedConfigurationID(msgHdr);
IntegratedConfigurationQueryOut
queryOut = port.query(queryIn);
List<MessageHeaderID>
lMsgHdr = queryOut.getIntegratedConfigurationID();
return lMsgHdr;
}
@SuppressWarnings("finally")
public
List<RestrictedIntegratedConfiguration>
readICO(List<MessageHeaderID> msgHdrList)
{
List<RestrictedIntegratedConfiguration>
createICOlist= new ArrayList<RestrictedIntegratedConfiguration>();
try {
IntegratedConfigurationReadIn
readIn =new IntegratedConfigurationReadIn();
readIn.getIntegratedConfigurationID().addAll(msgHdrList);
readIn.setReadContext(ReadContextCode.ACTIVE);
IntegratedConfigurationReadOut
readOut = port.read(readIn);
List<IntegratedConfiguration>
listreadOut = readOut.getIntegratedConfiguration();
for(int
i=0;i<listreadOut.size();i++)
{
RestrictedIntegratedConfiguration
resICO = new RestrictedIntegratedConfiguration();
resICO.setMasterLanguage(listreadOut.get(i).getMasterLanguage());
// Get Description
resICO.getDescription().addAll(listreadOut.get(i).getDescription());
//Get Set
MessageHeaderId/IntegratedCOnfiguration ID
resICO.setIntegratedConfigurationID(listreadOut.get(i).getIntegratedConfigurationID());
resICO.getIntegratedConfigurationID().setSenderComponentID(getTargetBS());
//Get Set
MessageHeaderId/IntegratedCOnfiguration ID
//Get Set InboundProcessing
resICO.setInboundProcessing(listreadOut.get(i).getInboundProcessing());
resICO.getInboundProcessing().getCommunicationChannel().setComponentID(getTargetBS());
//Get Set InboundProcessing
//Get Receivers
resICO.setReceivers(listreadOut.get(i).getReceivers());
//Get Receiver Interfaces
resICO.getReceiverInterfaces().addAll(listreadOut.get(i).getReceiverInterfaces());
//Get Outbound
Processing
resICO.getOutboundProcessing().addAll(listreadOut.get(i).getOutboundProcessing());
createICOlist.add(resICO);
}
}
catch (Exception e) {
e.printStackTrace();
}
finally{
return createICOlist;
}
}
