BizTalk XML to EDIFACT EDI assembler hitting exception - biztalk

I am currently trying to convert a XML file using XSLT to a EDIFACT format file.
Translation phase seems to be fine. By using a passthru send port i am able to obtain the EDIFACT file in XML format. However, once I try to pass the file to EDISend pipeline the I am hitting the exception
Error details: "Delimiter Set could not be read from the interchange. The attribute DelimiterSetSerializedData is missing from root node"
For this particular translation I am using EdifactInterchangeXml as the target schema.
Within the XSLT itself i have also declared the following segments:
<ex0:EdifactInterchangeXml DelimiterSetSerializedData="39:-1:-1:43:58:63:42:44:-1" xmlns:ex0="http://schemas.microsoft.com/Edi/Edifact">
<!--UNB-->
<ex1:UNB xmlns:ex1="http://schemas.microsoft.com/Edi/EdifactServiceSchema">
<UNB1>
<UNB1.1><xsl:text>UNOA</xsl:text></UNB1.1>
<UNB1.2><xsl:text>1</xsl:text></UNB1.2>
</UNB1>
<UNB2>
<UNB2.1><xsl:text>PSA</xsl:text></UNB2.1>
</UNB2>
<UNB3>
<UNB3.1><xsl:value-of select="userCSharp:Mandatory(substring($Desc_COMMID,1,35))"/></UNB3.1>
</UNB3>
<UNB4>
<UNB4.1><xsl:value-of select="substring($DT,3,6)"/></UNB4.1>
<UNB4.2><xsl:value-of select="substring($DT,9,4)"/></UNB4.2>
</UNB4>
<UNB5><xsl:text>(EBP)001</xsl:text></UNB5>
<xsl:if test="$Desc_COMMID">
<UNB10><xsl:value-of select="substring($Desc_COMMID,1,35)"/></UNB10>
</xsl:if>
</ex1:UNB>
<ex2:TransactionSetGroup xmlns:ex2="http://schemas.microsoft.com/Edi/Edifact">
<ex3:TransactionSet DocType="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006#EFACT_1911_BAPLIE" xmlns:ex3="http://schemas.microsoft.com/Edi/Edifact">
<ns0:EFACT_1911_BAPLIE>
<!--UNH-->
<UNH>
<UNH1><xsl:text>(EBP)0001</xsl:text></UNH1>
<UNH2>
<UNH2.1><xsl:text>BAPLIE</xsl:text></UNH2.1>
<UNH2.2><xsl:text>1</xsl:text></UNH2.2>
<UNH2.3><xsl:text>911</xsl:text></UNH2.3>
<UNH2.4><xsl:text>UN</xsl:text></UNH2.4>
<UNH2.5><xsl:text>SMDG15</xsl:text></UNH2.5>
</UNH2>
</UNH>
Any suggestion what could have caused the above error?

Related

Testable map base xml to flat file fails in BTS2013r2

I have lots of BTS2010 unit tests that check an XML file can be mapped to flat file.
I have developed my first of such tests on BTS2013r2 but on executing TestableMapBase.TestMap(_inputFilename, _inputType, outputFilename, _outputType), I get the error "Generate schema instance failure"
I've used reflector to debug the MS assemblies and got as far as the following line within CFrameworkSchemaTreeExtensions.cs of Microsoft.BizTalk.TOM.Adapter :
infoArray = instanceGenerator.GenerateInstance(filename, xmlInstance);
on executing, the infoArray is populated with the following error
ErrorInfo: hexadecimal value 0x00, is an invalid character. Line 2, position 1."
Prior to executing I have taken the content of xmlInstance, pasted into Notepad++ and used the Hex plugin to search for null characters (hex 0x00), there are none.
I have tried many different XML inputs to the maps on two different BizTalk development laptops and get the same result.
Has anyone been able to successfully run tests of XML to flat file in BTS2013r2?
Today I have created the most basic of solutions (1 BizTalk project + 1 unit test project) in order to test if this really is a Microsoft bug. It does seem that way because I got the same error when running this very simple test on a third BizTalk development laptop. I have added the source code to the following github repo: https://github.com/RobBowman/FFMapFailBTS2013r2
Make sure it is not an encoding issue. Finding a 0x00 at that position sounds like the input file is in UTF-16 format, while the processor is expecting UTF-8 or another single-byte encoding.
Microsoft have published a hotfix for this - see: https://social.msdn.microsoft.com/Forums/en-US/cacecbfd-8b71-409c-bd59-2eed26950f25/test-map-to-flat-file-in-bts-2013r2-does-this-ever-work?forum=biztalkgeneral

Process many EDI files through single MFX

I've created a mapping in MapForce 2013 and exported the MFX file. Now, I need to be able to run the mapping using MapForce Server. The problem is, I need to specify both the input EDI file and the output file. As far as I can tell, the usage pattern is to run the mapping with MapForce server using the input/output configuration in the MFX itself, not passed in on the command line.
I suppose I could change the input/output to some standard file name and then just write the input file to that path before performing the mapping, and then grab the output from the standard output file path when the mapping is complete.
But I'd prefer to be able to do something like:
MapForceServer run -in=MyInputFile.txt -out=MyOutputFile.xml MyMapping.mfx > MyLogFile.txt
Is something like this possible? Perhaps using parameters within the mapping?
There are two options that I've come across in dealing with a similar situation.
Option 1- If you set the input XML file to *.xml in the component settings, mapforceserver.exe will automatically process all txt in the directory assuming your source is xml (this should work for text just the same). Similar to the example below you can set a cleanup routine to move the files into another folder after processing.
Note: It looks in the folder where the schema file is located.
Option 2 - Since your output is XML you can use Altova's raptorxml (rack up another license charge). Now you can generate code in XSLT 2.0 and use a batch file to automatically execute, something like this.
::#echo off
for %%f IN (*.xml) DO (RaptorXML xslt --xslt-version=2 --input="%%f" --output="out/%%f" %* "mymapping.xslt"
if NOT errorlevel 1 move "%%f" processed
if errorlevel 1 move "%%f" error)
sleep 15
mymapping.bat
I tossed in a sleep command to loop the batch for rechecking every 15 seconds. Unfortunately this does not work if your output target is a database.

Get the real extension of a file vb.net

I would like to determine real file extension.
example :
file = "test.fakeExt"
// but the real extention is .exe // for security reason I wish to avoid using it!
How can I do that?
If you want to determine the extension you could use findmimefromdata.
It looks at the first part of the file to determine what type of file it is.
FindMimeFromData function
Sample code
The first two bytes of an .exe file are allways 'MZ'.
So you could read the binary file, and see if the first two bytes are MZ, then you know it's an .exe file...

Mxmlc generates different binary on same source

I'm compiling a single .as file into swf using mxmlc.
Whenever I run mxmlc, results are different in size even when the source code is not changed.
For example,
// Test.as
package
{
public class Test
{
}
}
And generates .swf using mxmlc :
mxmlc Test.as
and result size differs from 461 to 465 bytes.
I suppose that it's because of timestamp-like things in compiler, but I could not find how to fix or disable that. Any ideas on generating "same binary from same source" ? Thanks!
Finally, I found that metadata tag (Tag Type = 77) and undocumented 'product info' tag (Tag Type = 41) both contains compliation time.
I succeeded to remove timestamps by following steps :
1. open swf and un-zlib
2. clear timestamps in metadata tag and product info tag
3. re-zlib and make new .SWF
But I'm not happy with that, thus this needs extra work on SWF file. I want to find the easier way. there may be 'bypass product info' option on mxmlc..
You can find more information on SWF File structure and metadata tag on http://www.adobe.com/devnet/swf.html and product info on http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/
You need to override the metadata the compiler is writing into the resulting swf file. You can do this with the -raw-metadata compiler aguement.
Usage:
mxmlc -raw-metadata <XML_String> Test.as
Example:
mxmlc -raw-metadata '' Test.as
(Resulting swf is always 190 bytes).
1 : date in metadata:
mxmlc:
<metadata date=" " />
<raw-metadata></raw-metadata>
2 : timestamp in ProductInfo
download sdk source code,and modify the ProductInfo.java,let the timestamp keep same.and then update the ProductInfo.class in your_sdk_dir\lib\swfutils.jar
However,when i have done,Mxmlc also generates different binary on same source.
I think i can't change the compiler link order.

XForms bind element error

I am changing my code to use binds in XForms (which is better practice than using nodesets everywhere!) but I am getting errors.
The error message I receive is: "Error: XForms Error (8): id (data_criterion) does not refer to a bind element..."
From tutorials/guides I have been using, it seems as though this should work, but clearly I am missing something! (btw, I was modeling my binding code after the examples here: http://en.wikibooks.org/wiki/XForms/Bind)
I originally thought the problem was due to the fact I was using xf:select controls as opposed to xf:input like the examples, but even once I dumbed down my code to the most simplistic code, I still receive errors!
This is the model code I am using:
<xf:model id="select_data">
<xf:instance id="criteria_data" xmlns="">
<file>
<criteria>
<criterion></criterion>
</criteria>
</file>
</xf:instance>
<bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>
</xf:model>
As for the ui code, this is what I have:
<xf:input bind="data_criterion">
<xf:label>Enter criteria:</xf:label>
</xf:input>
The error message I receive is: "Error: XForms Error (8): id (data_criterion) does not refer to a bind element..."
Anyone have any insight to what the problem is? Also, is there any special usage of bindings and xf:select (with xf:itemset) controls that I should be aware of? (I am ultimately using a lot of xf:select controls on my form..)
Thanks in advance!
EDIT:
I ran the code through this validator, and I got this message (refers to the bind line):
"Warning: Should the following element have the XForms namespace applied?: bind (line 66)"
A couple of things you might want to change:
Not sure of this is the reason for the error, but the nodeset expression should be instance('criteria_data')/criteria/..., without file. Remember: instance() returns the root element, not the document node. (This one you took care by updating the question; good)
You are missing the xf on the bind. It should be: <xf:bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>.
See below a full example with your code, which works fine for me under Orbeon Forms:
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
<xhtml:head>
<xhtml:title>SO Bind</xhtml:title>
<xf:model id="select_data">
<xf:instance id="criteria_data" xmlns="">
<file>
<criteria>
<criterion>Gaga</criterion>
</criteria>
</file>
</xf:instance>
<xf:bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>
</xf:model>
</xhtml:head>
<xhtml:body>
<xf:input bind="data_criterion">
<xf:label>Enter criteria:</xf:label>
</xf:input>
</xhtml:body>
</xhtml:html>

Resources