on 07-20-2015 3:44 PM
Hello All,
For our one of the PI webservice we were using single values as input parameters but now it should accept multiple values or list as input. Please find below mentioned code :
private final List<String> purchaseOrderValues = new ArrayList<String>();
SPI_OrderStatus model = new SPI_OrderStatus();
IWDMessageManager manager = wdComponentAPI.getMessageManager();
IPublicSPIComponent.ISearchSPINode searchNode = wdContext.nodeSearchSPI();
IPublicSPIComponent.ISearchSPIElement searchElement = wdContext.currentSearchSPIElement();
OrderStatus_Request_Columns request = new OrderStatus_Request_Columns(model);
if(!this.purchaseOrderValues.isEmpty() || searchElement.getPurchase_Order() != null){
if(this.purchaseOrderValues.isEmpty()){
this.purchaseOrderValues.add(searchElement.getPurchase_Order());
}
request.setPurchase_Order(this.purchaseOrderValues);
}
********************************
request.setPurchase_Order(this.purchaseOrderValues); on this line when we are setting Purchase_order as input list I am getting below mentioned error on this line.
java.lang.ClassCastException: Cannot cast class java.lang.String to interface com.sap.tc.cmi.model.ICMIModelClass
Please let me know how to add those mutiple values to webservice input.
Regards,
Mayank Saxena
hi mayank,
this is occuring because , in yoru webserivce structure the node cardinality is 0..1 , so it cant accept multiple values , ask your PI /XI consultant to change the cardinality of that node to 0...n , then reimport that and implement above code.
Regards
Govardan Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello I did this to convert.
private List<String_Item> convertStringListToStringItemList(List<String> stringList, <Model_Name> model ){
List<String_Item> retVal = new ArrayList<String_Item>();
String_Item stringItem;
for(String s : stringList){
stringItem = new String_Item(model);
stringItem.setItem(s);
retVal.add(stringItem);
}
return retVal;
}
and while setting the request values:
request.set<attribute_name>(this.convertStringListToStringItemList(this.<Attribute_Name>, model);
BTW Thank you for your help.
Regards,
Mayank Saxena
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mayank,
It is type cast exception.. it is because of difference in source and destination fields' data types(as govardan said).
you will have to create elements of subnode and loop over string list and set field values one by one.
Also, Dont we bind in request to node again after creation ?
Regards,
Amey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.