C# BESApi.xsd Tuples

(imported topic written by JesperLarsen)

I popped into this issue a while ago and wanted to share as I spend… SOME time figuring out what was going on:

When I started out on the REST API i downloaded the
BESAPI.CS using that in my setup.

At some point I discovered that the tuples were not a part of the pre-generated BESAPI.CS.

The queries made would just be some simple ones like:
/api/query?relevance=(name of it, id of it) of bes computers

So to use the BESAPI.CS with tuples I had to get a hold on the BESAPI.XSD
(think I just downloaded it from here at that time:
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/90553c0b-42eb-4df0-9556-d3c2e0ac4c52/page/79fc6abc-a920-49fa-accd-ab4c50eab283
), and had to regenerate the BESAPI.CS using xsd.exe from the MS toolsets. Anyway, it would fail as the tuples in the xsd cause a cyclic reference. A cyclic reference is perfectly allowed (supporting unlimited nesting like a tuple within a tuple within a tuple…), but the xsd.exe does not support cyclic references. As a workaround to get the tuples in game I had to do the following.

  1. change the Tuples-part of the BESAPI.xsd from Type=“RelevanceResult” to another type (like Type=“ObjectName”)
  2. create a dummyobject somewhere in BESAPI.xsd (<xs:element name=“dummy” type=“RelevanceResult” />) forcing the RelevanceResult-Type to be created in the .cs file
  3. run the xsd.exe (xsd BESAPI.xsd /classes /namespace:MYNAMESPACE.BESAPI_Namespace) to generate BESAPI.cs
  4. edit BESAPI.cs to get rid of the dummy-field, and make the Tuple-Type (2 places) into RelevanceResult instead of string.

This way the tuples was accessible directly through the ‘generated but manually modified’ C# BESAPI.CS file.

/J

(imported comment written by jgstew)

Thanks for the info. You should file an RFE about this, point it to this post, and then provide the link to the RFE here so we can vote on it.

https://www.ibm.com/developerworks/rfe/execute?use_case=submitRfe

(imported comment written by JesperLarsen)

Hey

To my understanding IBM does only support the xsd-file as that is describing the XML format used in the communication between the IEM and whatever client consuming it.

The problem here is when I’m using C# some proxy classes for the XSD are generated using the xsd.exe tool from Microsoft, and the xsd.exe is the one messed up. (not the IBM part). So strictly speaking this is not an IBM issue as they afaik do not support the client libraries.

When looking back, it seems i was using the work of Daniel Moran (referred to by the TEM REST documentation). I tried to enter this issue in the BigFix.me-community with no luck, and afterwards emailed Daniel about this. Im not really aware if the BigFIX.me is an IBM initialive?

(imported comment written by jgstew)

BigFix.me is NOT an IBM initiative. It is a community site that Daniel Moran created in his spare time.

I do think that IBM has some responsibility to provide a solution to using the REST api in C# & .NET, even if the problem is technically related to Microsofts’ xsd.exe