Skip to Content
0
Former Member
Aug 14, 2015 at 05:18 PM

How to unmarshal web server response for PI channels status?

19 Views

Hi,

I'm exploring the option to manage PI channels through Java.

I have downloaded the ChannelAdmin.xsd and ran xjc and created the java classes.

"%java_home%\bin\xjc" -p test f:\ChannelAdmin.xsd

ActivationStateType.java

ChannelStateType.java

ChannelsType.java

ChannelType.java

ErrorInformationType.java

ObjectFactory.java

Then using http request I was able get a valid xml response with the channels status.

I tried several ways to unmarshal the response and go through the channels with no success.

For example:

JAXBContext jaxbContext = JAXBContext.newInstance(ChannelsType.class);

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

StringReader reader = new StringReader(response);

ChannelsType channelsType = (ChannelsType) unmarshaller.unmarshal(reader);

for (ChannelType channel : channelsType.getChannels().getChannel())

System.out.println(channel.getChannelName());

Can someone point me to a working example for managing channels using Java, or explain how to do it?

Thanks!