We are working on test harness project and was trying to develop a service that would read an xml from a file and create a request BO, which will then be input to the BPD using UCA.
To read an xml from a file, we leveraged the "Read Text File" integration service from the out-of-the-box SYSTEM DATA toolkit. The service seems to be straightforward in the sense that it takes the filePath (String) as input and returns the fileContents (String) as output. This is working as expected. When we try to consume the fileContents String and populate a BO using the following code, it throws the below exception.
tw.local.AddressBO = tw.system.serializer.fromXml(tw.local.fileContents);
com.lombardisoftware.core.TeamWorksRuntimeException: com.lombardisoftware.core.TeamWorksException: Type mismatch. Value "" must be instance of structured IBM BPM type. Java class found: java.lang.String
The type of the variable tw.local.AddressBO (AddressBO) has been defined as Address. Here is the definition for the Address type:
Note: This type is manually created in the process designer. The schema is provided just for understanding purpose.
<?xml version= "1.0" encoding= "utf-8"?> <xs:schema elementFormDefault= "qualified" xmlns:xs= "http://www.w3.org/2001/XMLSchema"> <xs:element name= "Address"> <xs:complexType> <xs:sequence> <xs:element name= "Recipient" type= "xs:string" /> <xs:element name= "House" type= "xs:string" /> <xs:element name= "Street" type= "xs:string" /> <xs:element name= "Town" type= "xs:string" /> <xs:element name= "PostCode" type= "xs:string" /> <xs:element name= "Country" type= "xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
The xml file that we are try to read is,
<?xml version= "1.0" encoding= "utf-8"?> <Address xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"> <Recipient>Mr. Walter C. Brown</Recipient> <House>49</House> <Street>Featherstone Street</Street> <Town>LONDON</Town> <PostCode>EC1Y 8SY</PostCode> <Country>UK</Country> </Address>
Unfortunately, we have technical issues with exporting the process application as a .twx file, so we cannot provide the .twx.
Any help on the above error will be appreciated.