cancel
Showing results for 
Search instead for 
Did you mean: 

Overhead in Response XML

michael_fallenbchel
Active Participant
0 Kudos

Hi experts,

short question - is there a way to remove the "overhead" from the XML response?

For example:


<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://esapxsgs.server.varta-g.net:8587/sap/opu/odata/sap/ZWWW_PRISMA_SRV;o=SGS_PROD/">

<id>

http://esapxsgs.server.varta-g.net:8587/sap/opu/odata/sap/ZWWW_TEST;o=SGS_PROD/valueTexts(fieldname=...')

</id>

<title type="text">

valueTexts(fieldname='FIELD',spras='D',value='411')

</title>

<updated>2014-06-02T12:25:11Z</updated>

<category term="ZWWW_TEST.valueTexts" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<link href="valueTexts(fieldname='FIELD',spras='D',value='411')" rel="edit" title="valueTexts"/>

<content type="application/xml">

<m:properties>

<d:fieldname>FIELD</d:fieldname>

<d:spras>D</d:spras>

<d:value>411</d:value>

<d:text>Grills</d:text>

</m:properties>

</content>

</entry>

Now I don't need the link, the content type...best would be something like


<m:properties>

<d:fieldname>FIELD</d:fieldname>

<d:spras>D</d:spras>

<d:value>411</d:value>

<d:text>Grills</d:text>

</m:properties>

Is this possible?

Thanks

Michael

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

HI Michael,

We were also looking for 'clean' XML without the oData overhead and we found this cool XSLT Transformation that does that.

oData Atom to simple XML structure | Moshko&amp;#039;s blog

We changed it a bit and it should look like this or in case it doesn't work for you you can use it as a starting point and adjust it.

Here is our version:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" version="1.0">

   <xsl:output encoding="UTF-8" method="xml" version="1.0"/>

   <xsl:template match="/">
     <document>
       <meta>
       </meta>
       <business>
         <xsl:apply-templates/>
       </business>
     </document>
   </xsl:template>

   <xsl:template match="/a:feed">
     <xsl:if test="a:link/@title">
       <xsl:element name="{a:link/@title}">
         <xsl:apply-templates select="a:entry"/>
       </xsl:element>
     </xsl:if>
   </xsl:template>

   <xsl:template match="a:entry">
     <xsl:if test="a:link/@title">
       <xsl:element name="{a:link/@title}">
         <xsl:for-each select="a:content/m:properties/*">
           <xsl:element name="{local-name()}">
             <xsl:value-of select="."/>
           </xsl:element>
         </xsl:for-each>
         <xsl:apply-templates select="a:link"/>
       </xsl:element>
     </xsl:if>
   </xsl:template>

   <xsl:template match="a:link">
     <xsl:if test="m:inline/a:feed">
       <xsl:element name="{m:inline/a:feed/a:link/@title}">
         <xsl:apply-templates select="m:inline/a:feed/a:entry"/>
       </xsl:element>
     </xsl:if>
     <xsl:if test="m:inline/a:entry">
       <xsl:apply-templates select="m:inline/a:entry"/>
     </xsl:if>
   </xsl:template>



</xsl:stylesheet>

Rergards,

Ilina

kammaje_cis
Active Contributor
0 Kudos

As Chandra said, it is not possible. Can I know why do you want to do that? that may give you useful answers.

michael_fallenbchel
Active Participant
0 Kudos

What I want to do is the following:

We have an external application (non-SAP) that I will with WebServices. Now we need also the "value help(F4)" in this external application.

For example for field WERKS I need all the descriptions for all the plants in all languages. Let's say we have 12 plants and 20 languages --> 240 entries

Field          plant

id               0001

language     EN

value          Plant Washington

Now I have also other fields, like SPART, MATKL, MEINS, VTWEG,...that means I have at the end an XML file of 61 MB only for one language key! That's why I thought of reduzing the overhead.

Sure, JSON would be an option, but this is also a file of ~40 MB...

Maybe I have to think of a different way 🙂

If anyone has an idea just let me know. Nested table could be an option

FIELD

ID

VALUE

     DE

     EN

     RU

     SL

     ...

ChandraMahajan
Active Contributor
0 Kudos

generally the OData service consumption application should retrieve the information which is required to display and for further information, it should again send the request. it is request-response kind of communication where client will send request for every query and server(odata service) will just send the required information.

in your case, you should implement filter on entity set based on field language, plant etc so that you will be able to get all plants with description for language in question OR get single plant with description in all languages by filtering it based on plant.

This way you will be able to get minimal response payload and you XML file size will be less.

you may want to redesign your service so that just pass information which external application want to display and then if the options are changing(based on language or plant) then again query it.

Regards,

Chandra

kammaje_cis
Active Contributor
0 Kudos

~40 MB? that is crazy. Definitely you do not need all those value helps in one screen. So you need to create the entity and use filters for languages and type of drop down and fetch only those values.

From SP8, SAP also provides a tool to generate value help services.

https://help.sap.com/saphelp_gateway20sp08/helpdata/en/77/ec405224753607e10000000a441470/content.htm

regards

Krishna

ChandraMahajan
Active Contributor
0 Kudos

Hi,

it is not possible. This is the Odata response payload and it will be there.

at max you can try with ?$format=json which will output the details on JSON format but still it will contain some of the metadata related information.

Regards,

Chandra