IsoMessage 8583 XML c#

杀马特。学长 韩版系。学妹 提交于 2019-12-13 09:47:49

问题


While executing, I get the error at this location.
XDocument doc = XDocument.Parse(BuildIsoMessage.Properties.Resources.Deneme);//I Get the document from resources in this way.

       ` GenericPackager packager = new GenericPackager(doc.ToString());`

An unhandled exception of type 'org.jpos.iso.ISOException' occurred in jpos.dll.Additional information: Error reading <!DOCTYPE isopackager PUBLIC "-//jPOS/jPOS Generic Packager DTD 1.0//EN" "http://jpos.org/dtd/generic-packager-1.0.dtd"[]>

I am trying to build an ISO Message in c#. I converted Jar files into one dll file and using some of the namespaces using org.jpos.util; using org.jpos.iso; using org.jpos.iso.channel; using org.jpos.iso.packager; however I can not pack my xml file, it throws an error.

https://github.com/jpos/jPOS/blob/master/jpos/src/main/resources/packager/iso87ascii.xml


回答1:


Jpos dll worked fine when provided path like below

GenericValidatingPackager packager = new GenericValidatingPackager(); packager.readFile("c:/isoxml/iso8583binary.xml");




回答2:


This is too simple to use a 3rd party dll. Use xml linq :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            string xmlHeader =
                "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
                "<!DOCTYPE isopackager PUBLIC" +
                "        \"-//jPOS/jPOS Generic Packager DTD 1.0//EN\"" +
                "        \"http://jpos.org/dtd/generic-packager-1.0.dtd\" >" +

                "<!-- ISO 8583:1987 (ASCII) field descriptions for GenericPackager -->" +

                "<isopackager>" +
                "</isopackager>";


            //<isofield

            XDocument doc = XDocument.Parse(xmlHeader);
            XElement isoPackager = doc.Descendants("isopackager").FirstOrDefault();

            List<IsoField> isoFields = new List<IsoField>() {
                new IsoField() { id= 0, length= 4, name="MESSAGE TYPE INDICATOR", cClass = "org.jpos.iso.IFA_NUMERIC"},
                new IsoField() { id= 1, length= 16, name="BIT MAP", cClass= "org.jpos.iso.IFA_BITMAP"},
                new IsoField() { id= 2, length= 19, name="PAN - PRIMARY ACCOUNT NUMBER", cClass= "org.jpos.iso.IFA_LLNUM"}
                };

            foreach (IsoField isofield in isoFields)
            {
                isoPackager.Add(new XElement("isofield", new object[] {
                    new XElement("id", isofield.id),
                    new XElement("length", isofield.length),
                    new XElement("name", isofield.name),
                    new XElement("class", isofield.cClass)
                }));

            }
            doc.Save(FILENAME);

        }
    }

    public class IsoField
    {
        public int id {get; set;}
        public int length { get; set; }
        public string name { get; set; }
        public string cClass { get; set; }
    }

}


来源:https://stackoverflow.com/questions/47151159/isomessage-8583-xml-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!