Question Status

Suggested Answer
Mike Land asked a question on 28 Feb 2013 8:06 AM

Hello,

I have a button in my application which calls SendXMLOriginal to get data from Database and put it into Queue Messanger. After that a Batch Job uses XSLT-tranforming to manipulate resulting XML. Last phase is that XML data is stored into filesystem using FileAdapter,

I made a simple sample to show what I mean. The question is that how can I get rid of these Envelope, Header, Body, Endpoints etc tags because another application reads this file and it's XMLSchema and that Schema doesn't contain these Tags?

XSL-testfile

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<output>

XML-tags and data

</output>
</xsl:template>
</xsl:stylesheet>


Result


<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header><MessageId>{A7367491-1776-4ACF-BF26-307280602D93}</MessageId>
<SourceEndpoint>LocalEndpoint</SourceEndpoint>
<DestinationEndpoint>CEU</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read</Action>
</Header>
<Body>
<MessageParts xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<output xmlns="">

XML-tags and data

</output>
</MessageParts>
</Body>
</Envelope>

Br 

Mike

Reply
Suggested Answer
Mukesh Hirwani responded on 1 Mar 2013 1:20 AM

Hi Mike,

U need to add that transformation to Outbound transformations not in Outbound pipeline.

1. Outbound port > Processing options > Transform all responses: Outbound Transformations.

2. Outbound transformation form will open up. Click Manage Transformation will open form.

3. Click New > Provide Name & description

4. Click Load. Locate the XSLT file which i provided above. And save.

5. Come back to Outbound transformation form, click New and select Transformation name.

6. Reactive port.

Done.. :)

Mukesh Hirwani
http://mukesh-ax.blogspot.in/ 

   

Reply
Mukesh Hirwani responded on 28 Feb 2013 10:07 AM

Hi Mike,

You need to add a transformation like below:

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

 <xsl:stylesheet version="1.0" xmlns:wt="schemas.microsoft.com/.../Message" xmlns:xsl="www.w3.org/.../Transform">

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

<!--Copy all nodes from source-->

-<xsl:template match="@*|node()">-<xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy></xsl:template>

<!--Remove header, message parts, body and envelope tags-->

<xsl:template match="wt:Envelope/wt:Header"/>-<xsl:template match="wt:Envelope/wt:Body/wt:MessageParts"><xsl:apply-templates/></xsl:template>-<xsl:template match="wt:Envelope/wt:Body"><xsl:apply-templates/></xsl:template>-<xsl:template match="wt:Envelope"><xsl:apply-templates/></xsl:template></xsl:stylesheet>

Mukesh Hirwani
http://mukesh-ax.blogspot.in/ 

   

Reply
Mike Land responded on 28 Feb 2013 10:15 AM

Hello, Thanks a lot for your answer!

I will try it immediately tomorrow morning.

Thanks a lot,

Mike

Reply
Mike Land responded on 1 Mar 2013 12:38 AM

Hello Mukesh,

Your xsl works well in outside Dynamics AX. E.g tested it with Oxygen and no problem.

But when I configure xsl to Endpoint's Outbound pipeline to be used with AifXmlTransform and AX processes file and writes it into File System using File Adapter those tags are still there.

Have you any ideas if I need more configuration to Outbound / XSL handling or how AX's XML handling cycle actually works.

Best Regards,

Mike

Reply
Suggested Answer
Mukesh Hirwani responded on 1 Mar 2013 1:20 AM

Hi Mike,

U need to add that transformation to Outbound transformations not in Outbound pipeline.

1. Outbound port > Processing options > Transform all responses: Outbound Transformations.

2. Outbound transformation form will open up. Click Manage Transformation will open form.

3. Click New > Provide Name & description

4. Click Load. Locate the XSLT file which i provided above. And save.

5. Come back to Outbound transformation form, click New and select Transformation name.

6. Reactive port.

Done.. :)

Mukesh Hirwani
http://mukesh-ax.blogspot.in/ 

   

Reply
Mike Land responded on 1 Mar 2013 2:50 AM

Hello again and thanks!

Is this Outbound transformations feature also in AX 2009... Can't find it anywhere.

Best Regards,

Mike

Reply
Mukesh Hirwani responded on 1 Mar 2013 3:01 AM

Oh no idea in AX 2009..

You can try n follow below article:

technet.microsoft.com/.../aa496464.aspx

Mukesh Hirwani
http://mukesh-ax.blogspot.in/ 

   

Reply
Mike Land responded on 1 Mar 2013 3:25 AM

Hello,

Found an older topic with same problem

objectmix.com/.../793750-xslt-transform-full-xml-using-aif.html

Clip from topic 2009

"just checked what the pipeline-componets can do and what not.

In a pipeline-component you have only access to the "real" Message.

This means that you only have access to all subtags of the Bodyelement in

the XML-Message.

You have no access to the Header tag (and subtags) because these tag are not

generated at the time the pipeline-component get executed.

As a result, if need to transform the header of the message you must build

your own adapter to transform the headerinformation.

But please keep in mind, that you must "rebuild" or provide a valid AIF

header for all inbound messages. If a inbound message hasn't valid

headerinfromation, these message generates an error while AIF processing."

Aargh!!

Br

Mike

Reply
Mukesh Hirwani responded on 1 Mar 2013 3:44 AM

Yeah this looks great.

We can perform same with a new adapter or u can also consider using BizTalk to apply the transformation.

Mukesh Hirwani
http://mukesh-ax.blogspot.in/ 

   

Reply
Mike Land responded on 1 Mar 2013 8:03 AM

BTW: Thanks for answering to my questions!

Best Regards,

Mike

Reply