Experiences with SAP Gateway

"My foots always in my mouth i just can't stomach defeet" – Hilltop Hoods

Entityset Name issue in OData Browsers

leave a comment »

I have been testing the “OData Channel Generation Tool”

The OData Channel Generation Tool enables you to import an existing service description file and, from this, automatically generate implementations for data and metadata provisioning on the backend for exposure via SAP NetWeaver Gateway. [Source: SAP Netweaver Gateway: OData Channel Generation Tool |

I noticed for some of the services generated the collections didn’t work as expected in various OData Browsers.

For example in the OData Browser for some a runtime exception was thrown and in the Sesame Data Browser various collections were disabled.

 

Through trial and error I found for the EntitySet’s where a name was nominated different from the Entity, that name was not reflected in the Atom:Title which still had the generated <Entity>Collection convention.

eg.

Creating an EntitySet ‘Customers’ for the Entity Customer

lo_entity_type = model->get_entity_type( 'Customer' ).
lo_entity_set = lo_entity_type->create_entity_set( 'Customers' ).

<EntitySet Name="Customers" EntityType="ZNWGWSAMP.Customer" sap:content-version="1"/>
.
<app:collection href="CustomerCollection" sap:content-version="1">
 <atom:title>CustomerCollection</atom:title>
</app:collection>

EntitySet Name ≠atom:title turned out to be the cause of the OData Browser issues.

To manually set the EntitySet Name in the Model you set the member title (not the SAP member title)
* text-004 = |Customers|.
lo_entity_set->set_member_title( iv_text_key = 'zcl_nwind_model-004'
iv_text_obj_type  = /iwbep/cl_mgw_abs_model=>gcs_sap_text_object_types-text_symbol_class ).

Now the title and name are the same
<EntitySet Name="Customers" EntityType="ZNWGWSAMP.Customer" sap:content-version="1"/>
.
<app:collection href="Customers" sap:content-version="1">
 <atom:title>Customers</atom:title>
</app:collection>

And the OData Browsers are working as expected

  

The <atom:title> element, as specified in [RFC4287] section 4.2.14, MAY contain the name of the EntitySet…
[Source [MS-ODATA]: Open Data Protocol (OData) Specification – 2.2.6.2.1 Entity Set (as an Atom Feed Element)  ]

I think some of the LINQ and Silverlight libraries are enforcing this.

Advertisements

Written by rsol1

January 17, 2012 at 3:25 am

Posted in Uncategorized

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: