Domanda

I try to decode CDR file to convert it to XML

I've installed Java Compiler on my PC. I used this link http://www.asnlab.org/asndt/overview.html

I tried to decode my CDR file, but it is not working properly.

It show first 19 records correctly, and then it gives me error, I tried 2 different CDR files. And both of them shows only 19 records.

1st file gives me this error:

Record 20 org.asnlab.asndt.runtime.error.AsnRuntimeException: Can not invoke method 'valueOf()' 794995 at org.asnlab.asndt.runtime.conv.ReflectionEnumeratedConverter.toObject(ed:40) at org.asnlab.asndt.runtime.type.EnumeratedType.I(mc:126) at org.asnlab.asndt.runtime.type.ImplicitType.I(xc:152) at org.asnlab.asndt.runtime.type.SetType.I(gb:191) at org.asnlab.asndt.runtime.type.SetType.I(gb:158) at org.asnlab.asndt.runtime.type.ImplicitType.I(xc:152) at org.asnlab.asndt.runtime.type.ChoiceType.I(hc:183) at org.asnlab.asndt.runtime.type.SequenceType.I(xb:221) at org.asnlab.asndt.runtime.type.SequenceType.I(xb:46) at org.asnlab.asndt.runtime.type.ImplicitType.I(xc:152) at org.asnlab.asndt.runtime.type.AsnType.I(bb:354) at org.asnlab.asndt.runtime.type.ByteBuffer.decode(fc:18) at org.asnlab.asndt.runtime.type.AsnType.decode(bb:338) at Test.main(Test.java:20)

And 2nd file gives me this error:

Record 20 org.asnlab.asndt.runtime.error.InvalidTagException 229505 at org.asnlab.asndt.runtime.type.AsnType.I(bb:369) at org.asnlab.asndt.runtime.type.ByteBuffer.decode(fc:18) at org.asnlab.asndt.runtime.type.AsnType.decode(bb:338) at Test.main(Test.java:20)

I dont understand is it problem with my ASN.1 definition or not?

È stato utile?

Soluzione

This question is best asked of the vendor of the ASN.1 Tool you are using. Another possibility is to try other ASN.1 Tools such as one of those listed at the ITU-T ASN.1 Project page (http://www.itu.int/ITU-T/asn1/links/index.htm). There is also the free online ASN.1 Compiler and Encoder/Decoder you could try at http://asn1-playground.oss.com. This free online tool can give you a detailed analysis of your CDR to give you an idea of what is wrong.

Altri suggerimenti

The CDR file is not exactly in ASN.1 encoding format, there are spaces (ASCII 32) between records. One workaround is detect and filter out these spaces every time a record is decode, like the code sample here:

        byte[] content = FileUtils.readFileToByteArray(new File("CDR1"));
        ByteBuffer buffer = (ByteBuffer) Buffer.wrap(content, EncodingRules.BASIC_ENCODING_RULES);

        CDMACallDataRecords records = new CDMACallDataRecords();
        try {
            while (buffer.hasRemaining()) {
                CDMACallDataRecord ccdr = (CDMACallDataRecord) CDMACallDataRecord.TYPE.decode(buffer, CDMACallDataRecord.CONVERTER);
                records.records.add(ccdr);

                if (buffer.hasRemaining()) {
                    byte b = buffer.getByte();
                    while (b == 32 && buffer.hasRemaining()) {
                        b = buffer.getByte();
                    }
                    if (b != 32) {
                        buffer.position(buffer.position() - 1);
                    }
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(buffer.remaining());
        }

This error is not specified to ASN.1 encoding, so it is not ASN.1 Tools related.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top