Hello,
I am currently experimenting on usage of RTI web integration service between the publisher and subscriber that are C++ based.
I noticed that the data POST/GET is in either JSON/XML format.. What are the options available in the automatic data conversion/serialization to JSON/XML format?
The last option could be writing the converters for each and every type.
Thanks.
Uday
Hello Uday,
You can convert the data to XML or JSON using the API DDS_DynamicDataFormatter_to_xml or DDS_DynamicDataFormatter_to_json. Please, be aware that both DDS_DynamicDataFormatter_to_json() and DDS_DynamicDataFormatter_to_xml() are internal, and they are not included in the public Connext DDS API. You can use them but taking into account that their specification could change in the future.
To use this mechanism and convert a sample to XML/JSON format, you can serialize the sample to CDR buffer, instantiate a DynamicData sample, and finally, translate the DynamicData sample to XML or JSON.
In the following code snippets you can see all the steps that you can follow to perform this task:
1. Define the parameters that you will need to perform the conversion (DynamicData, CDR and JSON).
2. Initialize the TypeCode.
3. Initialize the type support:
4. Initialize the dynamic data:
For each sample that you want to convert, you would need to perform the following tasks:
5. Serialize the sample to the CDR buffer:
6. Instantiate the dynamic data with the cdr buffer:
7. Translate the dynamic data to JSON or XML:
Hope this fits your request.
Regards,
Manuel
Hi Manuel,
I accidentally got into this page, when I noticed that there was a response. I coninuosly monitored this thread for few weeks after which I left. I probably got an email which I didn't notice. Sorry for that.
In any case, thanks a lot for the detailed response. Will consider looking into it. For now, a python-way approach is being looked into in parallel.
Thanks.
Uday
Hi All,
Not sure if this is the right place for my question. If not, please let me know where I can post the question.
I was working with RTI Web Integration Service 5.2.3 EAR and we had to send any enumeration in the data via a http post operation as the ordinal value of the enumeration (int value). As I understand, with the latest version of RTI Web Integration service, it defaults to using the string representation of the enum instead.
This means we have to make quite a lot of changes in our code base. I wonder if there is a setting when starting the web integration service to have it continue to use the ordinal value instead of defaulting to the string value.
I tried to search for any documentation regarding this but was not successful.
Any help and/or recommendation shall be greatly appreciated.
Thank you,
Tri
Somehow my reply to this topic got lost. Anyways, you can modify the Apache Velocity template of the rtiddsgen to create your own serialization function using any JSON/XML or whatever library you'd like to use. It is pretty simple to do so.
Hi Tri,
In the write operation you can provide both the integer representation and the string representation of the Enumeration value; the parser takes care of transforming what you pass to the right format.
However, as you mentioned, the default representation for the READ operation has changed from 5.2.3 (Early Access Release) to 5.3.0 (General Access Release). Now, enumeration values are by default represented as strings as opposed to integers. Fortunately, there is a query parameter called
enumAsIntegers
that you can use to change this behavior (see Reference Documentation here); you will have to append it to your GET request as follows:Please, let me know if this would work for you and whether you have run into any other issues when upgrading.
Thanks,
Fernando.