cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping of complex structure in XI

Former Member
0 Kudos

Hi friends,

I have a RFC to SOAP scenario in XI. As a response message they have given a structure with single field in it. But when it is coming over, it has a complex structure, I need to break it to different fields in my internal table. The response I have is given below.

<Result><Response><FileID _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">1992143</FileID><AuthID xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="i4">195894</AuthID><MessageList _Inserted="1"><Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">Domain value is invalid for field FilePriority (Client Name), Priority Type (Cartus Name) . The value received was SFNR.</Message><Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">The Destination Location State/Province is invalid. The State/Province was deleted and appended to City/Town. The value was Chennai.</Message><Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">Received Authorized Initiator (Nambissan, Rajesh) is not an active contact for client/division, Default Initiator was used.</Message></MessageList></Response></Result>

From this I need to seperate the fileid, authid, messages seperately. Can anyone please suggest how I can do that.

Thanks in advance for your help.

Anjana.

Accepted Solutions (0)

Answers (2)

Answers (2)

GabrielSagaya
Active Contributor
0 Kudos

Please use following xsl file for your mapping

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/1999/XMLSchema/" xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance/">
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

   <xsl:template match="/">
<AuthID>
            <xsl:copy-of select="dt:Result/Response/AuthID" />
</AuthID>
<FileID>
            <xsl:copy-of select="dt:Result/Response/FileID" />
</FileID>
<Messages>
            <xsl:copy-of select="dt:Result/Response/MessageList/Message" />
</Messages>
   </xsl:template>
</xsl:stylesheet>

Edited by: Gabriel Sagaya Selvam on Jul 29, 2009 11:33 PM

Former Member
0 Kudos

Hi Anjana,

What you can do is ask for the dtd they are using to send the response. I mean not the soap response, with in the soap response and within the field they are using a dtd. So if you get that dtd then in response mapping use an xslt mapping with CDATA to break the payload which is in one field to the strcuture of the dtd. Then you can send to your RFC as required.

Regards,

---Satish

Former Member
0 Kudos

Thanks Satish for the response. I haven't done xslt mapping yet. Do you mind giving me some idea on to how I should do that.

Thanks,

Anjana.

Former Member
0 Kudos

Hi Anjana,

Check the code given by henrique in this thread.

You need to do this in altova xml spy and save this as .xsl file and then zip it and then import into imported archives. Then you can use this as xsl mapping in your interface mappings.

Also if you want more information search in SDN for CDATA.

Regards,

---Satish

prateek
Active Contributor
0 Kudos

This would be of your interest

/people/danny.deroovere/blog/2008/11/30/how-to-map-cdata-to-a-structured-message-in-xi

Another option could be use of Java mapping and using DOM/SAX parser to get the required value.

Regards,

Prateek

Former Member
0 Kudos

Hi,

I created a .xsl file using Altova MapForce with the result xml I got from the other system and xml created from my RFC.

I created a zip file using that .xsl and imported it in archives, and used it in Interface mapping. Now, it is not giving me any error but the mapping is not happening as I expected. I m getting some weird result.

The .xsl file is as follows:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n2="http://tempuri.org/message/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="urn:sap-com:document:sap:rfc:functions" xmlns:dt="urn:schemas-microsoft-com:datatypes" exclude-result-prefixes="dt n2 xs xsi xsl" xmlns="urn:sap-com:document:sap:rfc:functions">

<xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default"/>

<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<ns1:Z_PA_SAP_TO_CENDANT.Response>

<xsl:attribute name="xsi:schemaLocation">

<xsl:value-of select="'urn:sap-com:document:sap:rfc:functions C:/DOCUME~1/asankara/Desktop/Z_PA_SAP_TO_CENDANT.xsd'"/>

</xsl:attribute>

<xsl:variable name="var1_instance" select="."/>

<IT_ERROR>

<item><xsl:for-each select="$var1_instance/n2:AuthorizationResponse/Result/Response/MessageList/Message">

<ERROR_DESC>

<xsl:value-of select="string(.)"/>

</ERROR_DESC>

</xsl:for-each> </item>

</IT_ERROR>

<IT_RESPONSE>

<item>

<xsl:for-each select="$var1_instance/n2:AuthorizationResponse">

<FILEID>

<xsl:value-of select="number(string(Result/Response/FileID))"/>

</FILEID>

</xsl:for-each>

<xsl:for-each select="$var1_instance/n2:AuthorizationResponse">

<AUTHID>

<xsl:value-of select="number(string(Result/Response/AuthID))"/>

</AUTHID>

</xsl:for-each>

</item>

</IT_RESPONSE>

</ns1:Z_PA_SAP_TO_CENDANT.Response>

</xsl:template>

</xsl:stylesheet>

Should I make any changes in the file that is created in Mapforce?Please help.

Thanks,

Anjana.

Former Member
0 Kudos

Anjana,

Open Notepad and copy this code and save it as .xsl file. Then zip it and upload it as imported archive. I tested this mapping adn it is working.

Note: I tested with your sample payload and it is working. For other payload test once again.

<?xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/1999/XMLSchema/" xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance/">

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

<xsl:template match="/">

<AuthID>

<xsl:value-of select="//AuthID"/>

</AuthID>

<FileID>

<xsl:value-of select="//FileID" />

</FileID>

<Messages>

<xsl:value-of select="//Message" />

</Messages>

</xsl:template>

</xsl:stylesheet>

I tested with the payload:

<Result>

<Response>

<FileID _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">1992143</FileID>

<AuthID xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="i4">195894</AuthID>

<MessageList _Inserted="1">

<Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">Domain value is invalid for field FilePriority (Client Name), Priority Type (Cartus Name) . The value received was SFNR.</Message>

<Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">The Destination Location State/Province is invalid. The State/Province was deleted and appended to City/Town. The value was Chennai.</Message>

<Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">Received Authorized Initiator (Nambissan, Rajesh) is not an active contact for client/division, Default Initiator was used.</Message>

</MessageList>

</Response>

</Result>

Then I have the output as:

<?xml version="1.0" encoding="UTF-8"?>

<AuthID xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:xsd="http://www.w3.org/1999/XMLSchema/" xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance/">195894</AuthID>

<FileID xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:xsd="http://www.w3.org/1999/XMLSchema/" xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance/">1992143</FileID>

<Messages xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:xsd="http://www.w3.org/1999/XMLSchema/" xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance/">Domain value is invalid for field FilePriority (Client Name), Priority Type (Cartus Name) . The value received was SFNR.</Messages>

Regards,

---Satish

Former Member
0 Kudos

Hi Satish,

I don't know what I m doing wrong with this. But the response I m getting is

<?xml version="1.0" encoding="UTF-8" ?>

- <ns1:Z_PA_SAP_TO_CENDANT.Response xmlns:ns1="urn:sap-com:document:sap:rfc:functions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:sap-com:document:sap:rfc:functions C:/DOCUME~1/asankara/Desktop/Z_PA_SAP_TO_CENDANT.xsd">

- <IT_ERROR xmlns="urn:sap-com:document:sap:rfc:functions">

<item />

</IT_ERROR>

- <IT_RESPONSE xmlns="urn:sap-com:document:sap:rfc:functions">

- <item>

<FILEID>NaN</FILEID>

<AUTHID>NaN</AUTHID>

</item>

</IT_RESPONSE>

</ns1:Z_PA_SAP_TO_CENDANT.Response>

whereas I m expecting a response with numeric values for FILEID and AUTHID. I m using the same file I sent you. Do you know where I might be doing wrong?Please help. Thanks a lot for your help!

Regards,

Anjana.

Former Member
0 Kudos

Hi,

If you see in your code I see the line:

C:/DOCUME~1/asankara/Desktop/Z_PA_SAP_TO_CENDANT.xsd">

XI doesnot refer to this location. Can you give your final output schema. I will use it and will come up with the xsl mapping.

Regards,

---Satish

Former Member
0 Kudos

Can you please give me an example on how I can do that?

Thanks,

Anjana.

Former Member
0 Kudos

Please give the structure of RFC to where you need to send. I will come up with xsl mapping.

Regards,

---Satish

Former Member
0 Kudos

Anjana,

You need to do two mappings for your issue:

Webserviceresponsexsd --> xsl --> target1 (create a message type same like the one which is in your string)

target1 --> graphical mapping --> target2 (which is your rfc response).

Regards,

---Satish

Former Member
0 Kudos

Hi,

I have done the xsl mapping and it is working in altova xmlspy, when I give the input as what I see in sxmb_moni.

The data I can see in moni is like this.

*<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>*

*- <!-- Call Adapter*

-->

*- <SOAPSDK1:AuthorizationResponse xmlns:SOAPSDK1="http://tempuri.org/message/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">*

*<Result><Response><FileID _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">1992449</FileID><AuthID xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="i4">196084</AuthID><MessageList _Inserted="1"><Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">The Destination Location State/Province is invalid. The State/Province was deleted and appended to City/Town. The value was Chennai.</Message><Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string">Received Authorized Initiator (Nambissan, Rajesh) is not an active contact for client/division, Default Initiator was used.</Message></MessageList></Response></Result>*

*</SOAPSDK1:AuthorizationResponse>*

But when I download the xml file from moni, and take the source code of it, it looks like this:

*<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><!-- Call Adapter --> <SOAPSDK1:AuthorizationResponse xmlns:SOAPSDK1='http://tempuri.org/message/' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'><Result>&#60;Response&#62;&#60;FileID _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string"&#62;1992449&#60;/FileID&#62;&#60;AuthID xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="i4"&#62;196084&#60;/AuthID&#62;&#60;MessageList _Inserted="1"&#62;&#60;Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string"&#62;The Destination Location State/Province is invalid. The State/Province was deleted and appended to City/Town. The value was Chennai.&#60;/Message&#62;&#60;Message _Inserted="1" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string"&#62;Received Authorized Initiator (Nambissan, Rajesh) is not an active contact for client/division, Default Initiator was used.&#60;/Message&#62;&#60;/MessageList&#62;&#60;/Response&#62;</Result></SOAPSDK1:AuthorizationResponse>*

I tried testing my mapping in altova xmlspy using the file I downloaded from moni(not the copied one) and it is giving me blank output. So I doubt its about the format of the data I m getting from the other system. It has bad characters like '#','&' etc.whereas I don't see data like this for other interfaces.

Can you please help me identify the issue and solve this.

Thanks in advance for any help!

Anjana.