Send X12 AS2 Document with BizTalk 2013 - biztalk

I asked a question about EDI before EDI X12 Implementation with C#
And i'm need help again. We have decided to use BizTalk 2013, i was able to install BizTalk 2013, i need some assistance.
Our partner sent a document about AS2 Trading Partner Setup and some certificates for both production and test enviroment. The information in this document is:
AS2 Identifier and URL
MDN: SHA1
Encryption Algorithm: Triple DES
MDN Delivery Type (Synchronous/Asynchronous):
Synchronous (Asynchronous also supported)
Request Signed Receipt: Yes
Software: Cyclone Interchange
Payload Security Type (e.g., Signed, SignedAndEncrypted, etc.): SignedAndEncrypted
I read the tutorial below and try to integrate to our solution
http://msdn.microsoft.com/en-us/library/bb727687(v=bts.80).aspx
Steps i did;
Create Visual Studio Project that contains X12 850 document schema and deploy it.
Created one way receive port to receive edi document we create.
Install the certificate to Local computer > Other people
Created static solicit-response send port to send edi document to our partner and select the certificate for encrypt message.
Created parties for us and for our partner.
Created agreement between us and our partner. Select AS2 for protocol.
I did following changes in "Us > Our Partner" tab.
In Acknowledgements(MDNs) page, i selected Process inbound MDN into MessageBox for routing/delivery options and Request MDN boxes.
In Validation page i selected Message should be encrypted and DES3.
In Send Ports i selected port that i created.
Now when i copy file to receive port i created, BizTalk gives an error like this:
The AS2 Decoder encountered an exception during processing. Details of the message and exception are as follows: AS2-From:"" AS2-To:"" MessageID:"" MessageType: "unknown" Exception:"An AS2 message was received that did not contain the AS2-From header."
My test EDI document looks like (I tried with header information, and without header, results are same)
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
AS2-From: ZZUS
AS2-To: ZZTHEM
AS2-Version: 1.0
Message-ID: AS2Message-001
ISA*00* *00* *ZZ*US *ZZ*THEM
*130530*1244*U*00401*00001234*0*P*:
GS*PO*US*THEM*20130530*1244*1234*X*004010
ST*850*1234
BEG*00*SA*PO1234**20130530**ZZ
ITD*ZZ***20080101*0**0*******1
DTM*002*20130615
N1*ST*US*92*1426136
N3*6719 THEALL RD STE B
N4*HOUSTON*TX*77066-1215*US
PER*ZZ*No Contact specified
PO1*1*1*CA***VN*MSC097030
PID*F****HAND SANITIZER,EPI-CLENZ,4 OZ,70% ETHYL
CTT*1
SE*44*1234
GE*1*1234
IEA*1*00001234
Btw, i'm creating document by C# code, is there any easy way BizTalk provides to create/read X12 documents like this?
Any help would be appreciated.
Thanks.

With any EDI application worth its salt (and I wouldn't put BizTalk in that category), you should be able to create a map. With all the abstraction layers that BizTalk uses, you should be able to use the various "adapters", including the EDI adapter to create a "map". The map should allow you to transform your source to a target, and then connect to another adapter to control workflow and delivery.
Here is a link to an example workflow for you: http://www.nullskull.com/a/1339/using-edi-adapter-to-sendreceive-po-within-trading-partners.aspx

Related

Biztalk EDI - View final outbound X12 interchange

I've been running Biztalk 2004 with the Covast EDI accelerator since 2004. I'm currently upgrading to Biztalk 2013 R2 and having difficulty viewing the final outbound interchange document for an X12 document. My final destination is an AS2EDISend port.
I can see the interchange information (sender/receiver/control ID) in the report "EDI Interchange and Correlated ACK status". I can see more information by viewing the "Interchange Status and ack Details" screen. I can view the transaction set. I can view the transaction set details and from there get the final transaction set (ST to SE segment) in raw ASCII format.
But I can't see the raw final outbound interchange complete with the ISA/GS segments.
I do have tracking turned on and when I look at the tracked message events, I can see receive/send events for the AS2EDI pipeline. When I look at the message on the receive event, it's the XML representation of the transaction set. When I look at the message on the send event, it's already been AS2 encoded and I'm unable to view the raw ASCII EDI file complete with ISA/GS segments.
Am I missing something? Is there somewhere else to look? Will I have to configure a secondary send port which only does EDISend and write to my filesystem and maintain/archive that information myself?
The ISA and GS segments will be promoted into the context of the message, as ISA_String and GS_String respectively. The individual segment values are also promoted as ISA01, ISA02, etc. and GS01, GS02, etc.
Since you're using AS2, I think the easiest solution would be to create a send port group, use your existing send port with AS2 in it, and another SendPort with EdiSend using the FILE adapter. Another option would be to add a custom pipeline component in the Encode stage that would archive the results from the EDI Assembler - which would be more efficient but more work as well.
if you simply want to see the interchange message for testing/develop propose, Put the send port to stop state, the message in this port will suspend. then you can view/save the message in admin console.
if you need a solution to "see" the interchange message in operation level. a second send port is an option.

BizTalk 2013 log file to debug EDI application

I am new to BizTalk. I wrote an application to receive an EDI 850 (Purchase Order) and to output a corresponding xml file in a separate folder location.
In the project I deployed to biz talk I have an 850 schema, my result xml schema, a map from the original EDI 850 to my new xml schema, and a pipeline with a flat file assembler pointing to my new schema.
I set it up like what is explained in the following tutorial: http://msdn.microsoft.com/en-us/library/bb226541.aspx. I did run through this tutorial first and it worked for me.
I dropped the edi file into my receive folder and it is picked up. But my result file in the send to folder is empty.
The event viewer does not show any errors.
I would like to know if there is a log file that would show where something may have been configured incorrectly.
To RECEIVE an EDI file, you need a receive pipeline with an EDI disassembler.
The EdiReceive pipeline in the EDI BizTalk application is what you are looking for most likely. By default this pipeline does the necessary tracking, so you should be able to see in the "Tracked Message Events".
You should always try to do it step by step:
EdiReceive disassemble to XML file and subscribe to that file using a send port.
Once this works, try mapping the result with a 'Test Map' using VS. You might notice you did something wrong there.
Once this works, deploy your mapping to BizTalk and set it in the send port as an outbound map, so it gets executed.
Hope this helps.
Use the BizTalk Server Administration Console and look at Tracked message events, that should show you if BizTalk received it and where it went.

Storing or looking up ISA numbers with BizTalk EDI

My company uses BizTalk for our EDI and AS2 communications. One periodic issue is that a VAN or similar partner we transmit with will want to know whether we received a file by it's ISA #. We currently do use the ISA # for routing within our ports, but I can't seem to find anywhere that this information is stored in BizTalk. Is there a way to look up an EDI message that BizTalk recieved by ISA#? Or perhaps someway I could get a hold of it and store it on my own?
If you're not explicitly using Business Activity Monitoring (BAM) to track this, you may be able to use message tracking.
If you have:
message tracking turned on for the message properties at a point in processing the messages when the ISA number is used, and
if the ISA number is promoted in a published schema (which I'm guessing it is, if you're using the out-of-the-box EDI stuff)
...then you could use the admin console to look for tracked messages with that schema and based on the particular field in the schema (e.g., EDI.ISA08 or EDI.ISA06). Of course, if you are mapping the ISA# to a particular party through your BizTalk configuration, then you would just need to search for Tracked Message Events where the Party Name equals the name you configured for that ISA#.
There is also built-in EDI tracking (see http://msdn.microsoft.com/en-us/library/bb226464(v=bts.10).aspx), with its own reports, but I'm not familiar with it enough to say whether or not it'll give you exactly what you need.
Otherwise, you will want to look at setting up BAM to save the ISA info that you need.
These fields are available inside the Biztalk message if you do EDI receive.
msgIn(EDI.ISASegment) contains all ISA segments. Then you can do substring on control numbers and then put it in your outgoing filename:
ctrlnum (variable) = msgIn(EDI.ISA13)
newfilename = FILE.ReceivedFileName + ctrlnum ;
This way each control number will show up in your filename and you don't even need to open the file or check tracked messages.

Programmatically open an email from a POP3 and extract an attachment

We have a vendor that sends CSV files as email attachments. These CSV files contain statuses that are imported into our application. I'm trying to automate the process end-to-end, but it currently depends on someone opening an email, saving the attachment to a server share, so the application can use the file.
Since I cannot convince the vendor to change their process, such as offering an FTP location or a Web Service, I'm stuck with trying to automate the existing process.
Does anyone know of a way to programmatically open an email from a POP3 account and extract an attachment? The preferred solution would reside on a Windows 2003 server, be written VB.NET and secure. The application can reside on the same server as the POP3 server, for example, we could setup the free POP3 server that comes with Windows Server and pull against the mail file stored on the file system.
BTW, we are willing to pay for an off-the-shelf solution, if one exists.
Note: I did look at this question but the answer points to a CodeProject solution that doesn't deal with attachments.
Try Mail.dll email component, it's very affordable, supports attachments national characters and is easy to use, it also supports SSL:
Using pop3 As New Pop3()
pop3.Connect("mail.server.com")
pop3.Login("user", "password")
Dim builder As New MailBuilder()
For Each uid As String In pop3.GetAll()
' Receive email message'
Dim mail As IMail = builder.CreateFromEml(pop3.GetMessageByUID(uid))
'Write out received message'
Console.WriteLine(mail.Subject)
'Here you can use mail.Attachmets collection'
For Each attachment As MimeData In mail.Attachments
Console.WriteLine(attachment.FileName)
attachment.Save("c:\" + attachment.FileName)
' you can also use attachment.Data here'
Next attachment
Next
pop3.Close(true)
End Using
You can download it here: http://www.lesnikowski.com/mail.
possible duplication of Reading Email using Pop3 in C#
Atleast, there's a shed load of suggestions there that you may find useful
I'll throw in a late suggestion for a more generalized "download POP3 messages and extract attachments" solution using existing software and minimal programming. I needed to do this for a client who switched to receiving faxes via email and was not pleased with manually saving the attachments to a location where they could be imported into an application.
For downloading messages on *nix systems fetchmail seems to be the standard and is very capable, but I chose mpop for both simplicity and Windows compatibility (but it is cross-platform). If mpop hadn't done the trick for me, I probably would have ended up doing something with the Python-based getmail, which was created when fetchmail's development stalled for a time (it's since resumed).
Mpop is controlled either via command line or configuration file, so I simply created multiple configuration files and specify via command line which file to load. I'm using it in "Exchange pickup directory" mode, which means it simply downloads the messages and drops them as text (.eml) files in a specified directory.
For extraction of the message attachments, UUDeview appears to be the standard (I'm using the Windows port of UUDeview) across just about any system you could want with just about any features you could want. My main alternative to this was a much-less-capable Python script that I'd developed for a different client back in 2007, but I'm happy to go with a precompiled executable over either installing Python or packaging with any of the Python-to-exe options.
Finally there's the configuration - along with the two mpop configuration files mentioned above (which I could do away with by using command-line options), I also have two 2-line .cmd files launched every 10 minutes by scheduled task - the first line to launch mpop to download into a working directory and the second line to launch UUDeview and extract attachments of specified types (.pdf or .tif) then delete each file from which it extracted attachments. Output is sent to another directory from which staff can directly attach files as needed.
This is overall not the most elegant way to reach these ends, but it was quick, simple, functional and reasonably robust - at each stage if something goes wrong it fails such that no data is lost. The only places where data could be lost are any non-attachment messages being sent to the dedicated fax email addresses, and even those will sit in the processing directory and be caught eventually.

BizTalk 2006 Tutorial 1: EDI-to-XML Document Translation

I cannot find the translated file after running the solution in BizTalk 2006 Tutorial Lesson 3: Run the EDI-to-XML Solution.
It should be placed in the c:\Program Files\Microsoft BizTalk Server 2006 \EDI\Adapter\Getting Started with EDI\Northwind\In folder.
The Base EDI adapter picks up the file in c:\Documents and Settings\All Users\Application Data\Microsoft\BizTalk Server 2006 \EDI\Subsystem\Documents\PickupEDI folder, but I cannot find the translated file in the X-12 4010 850 document format.
I'm not immediately familiar with the tutorial you mention, but below are steps to find where any document has gone to in BizTalk.
First two places to check are in the event viewer and in the BizTalk Server Administration Console.
Check you have no errors in the event viewer.
In the admin console, click on the BizTalk Group in the left hand window and you should see two columns in the right hand pane, Work in Progress and Suspended Items. Click on Running service instances and Suspended service instances. Check that you message is not delayed for any reason (a Send Port being turned off perhaps).
Next, from Start -> All Programs -> Microsoft BizTalk Server 2006 select the Health and Activity Tracking (HAT) tool.
In HAT, select Queries -> Most recent 100 service instances. Find the pipeline that will have wrote out your file, right click the service instance and select Message Flow. In the message flow view you should see in the URL the disk location where your file was written to.
(You can also look in the admin console to check where the send port is pointing)
Thanks for your suggestion regarding how to troubleshoot an issue of BizTalk Server from generic point of view. It did help. I have resolved this problem by reading error logs.
Here is the error:
Access denied. The client user must be a member of one of the following accounts to perform this function.
SSO Administrators: SSO Administrators
SSO Affiliate Administrators: SSO Affiliate Administrators
Application Administrators: BizTalk Server Administrators
Application Users: BizTalk Application Users
It works now after adding a service account to "SSO Administrators" and restart all BizTalk related services.

Resources