B4J Question inline java erorr

behnam_tr

Active Member
Licensed User
Longtime User
i have this java code work good in intelij ide and eclips

Code:
import ir.gov.tax.tpis.sdk.content.api.DefaultTaxApiClient;
import ir.gov.tax.tpis.sdk.content.dto.*;
import ir.gov.tax.tpis.sdk.transfer.api.SimpleTransferApiImpl;
import ir.gov.tax.tpis.sdk.transfer.api.TransferApi;
import ir.gov.tax.tpis.sdk.transfer.config.ApiConfig;
import ir.gov.tax.tpis.sdk.transfer.dto.AsyncResponseModel;
import ir.gov.tax.tpis.sdk.transfer.dto.PacketResponse;
import ir.gov.tax.tpis.sdk.transfer.impl.encrypter.DefaultEncrypter;
import ir.gov.tax.tpis.sdk.transfer.impl.normalize.SimpleNormalizer;
import ir.gov.tax.tpis.sdk.transfer.impl.signatory.SignatoryFactory;
import ir.gov.tax.tpis.sdk.content.api.TaxApi;
import ir.gov.tax.tpis.sdk.utils.TaxUtils;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public  class taxv1 {

    private static final String ORG_PUBLIC_KEY = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxdzREOEfk3vBQogDPGTMqdDQ7t0oDhuKMZkA+Wm1lhzjjhAGfSUOuDvOKRoUEQwP8oUcXRmYzcvCUgcfoRT5iz7HbovqH+bIeJwT4rmLmFcbfPke+E3DLUxOtIZifEXrKXWgSVPkRnhMgym6UiAtnzwA1rmKstJoWpk9Nv34CYgTk8DKQN5jQJqb9L/Ng0zOEEtI3zA424tsd9zv/kP4/SaSnbbnj0evqsZ29X6aBypvnTnwH9t3gbWM4I9eAVQhPYClawHTqvdaz/O/feqfm06QBFnCgL+CBdjLs30xQSLsPICjnlV1jMzoTZnAabWP6FRzzj6C2sxw9a/WwlXrKn3gldZ7Ctv6Jso72cEeCeUI1tzHMDJPU3Qy12RQzaXujpMhCz1DVa47RvqiumpTNyK9HfFIdhgoupFkxT14XLDl65S55MF6HuQvo/RHSbBJ93FQ+2/x/Q2MNGB3BXOjNwM2pj3ojbDv3pj9CHzvaYQUYM1yOcFmIJqJ72uvVf9Jx9iTObaNNF6pl52ADmh85GTAH1hz+4pR/E9IAXUIl/YiUneYu0G4tiDY4ZXykYNknNfhSgxmn/gPHT+7kL31nyxgjiEEhK0B0vagWvdRCNJSNGWpLtlq4FlCWTAnPI5ctiFgq925e+sySjNaORCoHraBXNEwyiHT2hu5ZipIW2cCAwEAAQ==";
    private static final String ORG_KEY_ID = "6a2bcd88-a871-4245-a393-2843eafe6e02";
    private static final String PRIVATE_KEY_FILE = "C:/private.txt";
    private static final String MEMORY_ID = "A2HGE9";
    private TaxApi taxApi;
    private String token;
    private String uid;
    private String referenceNumber;

    public static void main(String[] args) throws URISyntaxException, IOException {

         System.out.println("hello world");

        taxv1 test = new taxv1();
        test.setUp();
        test.getServerInformation();
       // test.getToken();
//        test.sendInvoices();
//        test.inquiryByUID();
//        test.inquiryByReferenceId();
//        test.inquiryByTime();
//        test.inquiryByTimeRange();
//        test.getFiscalInformation();
//        test.getEconomicCodeInformation();
//        test.getServiceStuffList();
//        try {
//            Thread.sleep(6000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        test.inquiryByReferenceId();
      }

    public void setUp() throws URISyntaxException, IOException {
        ApiConfig apiConfig = new ApiConfig()
                .baseUrl("https://sandboxrc.tax.gov.ir/req/api/self-tsp")
                .normalizer(new SimpleNormalizer())
                .apiVersion("v1")
                .encrypter(new DefaultEncrypter(ORG_PUBLIC_KEY, ORG_KEY_ID))
                 .transferSignatory( SignatoryFactory.getInstance().createPKCS8Signatory( new File(PRIVATE_KEY_FILE), null));
        TransferApi transferApi = new SimpleTransferApiImpl(apiConfig);
        taxApi = new DefaultTaxApiClient(transferApi, MEMORY_ID);
    }

    public String getServerInformation() {
        ServerInformationModel serverInformation =  taxApi.getServerInformation();
        System.out.println("success load server information: " + serverInformation);
        return  serverInformation.toString();
    }

    void getToken() {
        TokenModel token = this.taxApi.requestToken();
        this.token = token.getToken();
        if (this.token != null && this.token.length() > 0) {
            System.out.println("success login, token: " + this.token);
        } else {
            System.out.println("error in login");
            System.exit(-1);
        }
    }


}

i want to use inline but i get error for this codes
B4X:
    Dim jo As JavaObject
    jo.InitializeContext
'    jo.InitializeStatic("taxv1")
'    jo.InitializeNewInstance("b4j.example.main$taxv1",Null) ' this points to the package name where the java is
'    jo.RunMethod("setUp",Null)

private.txt file attached
Download the required jar files from the link below
https://www.dropbox.com/scl/fi/ufyz...0.34.zip?rlkey=v9b6agb1huh45l5jccsxkzslo&dl=0
 

Attachments

  • Private.txt
    1.7 KB · Views: 32

Daestrum

Expert
Licensed User
Longtime User
Guessing at the error
try
B4X:
public static class taxv1 {

instead of
B4X:
public  class taxv1 {
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Can you post the error you get from post #1.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
As an afterthought.
B4X:
jo.InitializeContext
Is B4A only.
 
Upvote 0
Top