on 10-14-2013 4:49 PM
Hi All,
I am trying to read communication channel values using communication channel webservice. The program works fine, however the adapter specific values that I receive from the program are unreadable.
Program:
public static void main(String[] args) {
DirApiReadCommChannel directory = new DirApiReadCommChannel();
List<CommunicationChannelType> cc = directory.readCommunicationChannelIn(directory.queryCommunicationChannelIn());
System.out.println("CommunicationChannels:");
for (int i = 0; i < cc.size(); i++) {
// display id
System.out.println(i);
System.out.println(cc.get(i));
System.out.println(cc.get(i).getAdministrativeData());
System.out.println(cc.get(i).getDescription());
System.out.println(cc.get(i).getDirection());
System.out.println(cc.get(i).getAdapterSpecificAttribute());
System.out.println(cc.get(i).getAdapterSpecificTableAttribute());
System.out.println(cc.get(i).getModuleProcess());
System.out.println(cc.get(i).getTransportProtocol());
System.out.println(cc.get(i).getAdapterMetadata());
System.out.println("-----------------------------------------------------------------------------------");
}
Output:
-----------------------------------------------------------------------------------
1
com.sap.xi.basis.CommunicationChannelType@18a9fc8
com.sap.xi.basis.ObjectAdministrativeDataType@197436b
[com.sap.xi.basis.global.LONG_DescriptionType@1cb5cfc]
RECEIVER
[com.sap.xi.basis.GenericPropertyType@45b098, com.sap.xi.basis.GenericPropertyType@14cdfcf]
com.sap.xi.basis.ModuleProcessType@8f474f
HTTP
com.sap.xi.basis.DesignObjectIDType@92b39f
-----------------------------------------------------------------------------------
com.sap.xi.basis.CommunicationChannelType@9bad5a
com.sap.xi.basis.ObjectAdministrativeDataType@18a577d
RECEIVER
[com.sap.xi.basis.GenericPropertyType@175deb1, com.sap.xi.basis.GenericPropertyType@16f6a81]
[com.sap.xi.basis.GenericPropertyTableType@1ebec47, com.sap.xi.basis.GenericPropertyTableType@1e5348f, com.sap.xi.basis.GenericPropertyTableType@ddb2e7]
com.sap.xi.basis.ModuleProcessType@10c624a
File
com.sap.xi.basis.DesignObjectIDType@90067
Please Advice.
Hi Vicky,
Your for loop should look like this
for (int i = 0; i < cc.size(); i++)
{
// display id
//System.out.println(i);
//System.out.println(cc.get(i));
System.out.println("Responsible = "+cc.get(i).getAdministrativeData().getValue().getResponsibleUserAccountID().getValue());
System.out.println("Changed by = "+cc.get(i).getAdministrativeData().getValue().getLastChangeUserAccountID().getValue());
System.out.println("Description = "cc.get(i).getDescription().get(0).getValue().getValue());
System.out.println("Direction = "+cc.get(i).getDirection().getValue());
for(int j=0;j<cc.get(i).getAdapterSpecificAttribute().size();j++)
{
System.out.println("Name="+cc.get(i).getAdapterSpecificAttribute().get(j).getName().getValue();
System.out.println("Value="+cc.get(i).getAdapterSpecificAttribute().get(j).getValue().getValue();
}
System.out.println("TP="+cc.get(i).getTransportProtocol().getValue());
System.out.println("Adapter type= "+cc.get(i).getAdapterMetadata().getValue().getName().getValue());
System.out.println("-----------------------------------------------------------------------------------");
}
Message was edited by: Anand V D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Anand. I was able to pull all the required values following your suggestion.
Next thing if you could guide me is how to write all these values to an excel.
what files do i need to import. I have imported:
/*import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.lang.Object;
import java.util.Set;
import java.io.File;
import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;*/
When I try to populate the excel cells with: cell.setCellValue((String) cc.get(i)). I get an error saying cannot convert List<CommunicationChannelType> to String.
Thanks.
Hello Vicky,
you print the internal object reference, not the text value of the objects. Anand's approach is the way to go.
Regards,
Jörg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.