【问题标题】:Calling a Acumatica report using screen based soap api in java使用Java中的基于SCOAP API调用Acumatica报告
【发布时间】:2019-11-05 00:23:32
【问题描述】:

我正在使用 Java 获取 Acumatica 报告,该报告使用基于屏幕的SOUP Web 服务 (使用Apache CXF 生成的代码)。我感兴趣的报告是Transactions for Periods in Finance。我知道如何将命令传递给 Web 服务以指定返回的结果,但我不知道如何传递参数。

我要传递的参数是fromPeriodtoPeriodLedgerfromAccounttoAccount。我是否将参数作为过滤器或其他方式传递?如果作为过滤器,我如何创建过滤器对象?

我在 Java 中找不到任何调用 Acumatica SOAP Web 服务的示例,因此非常感谢任何帮助。


screen = service.getScreenSoap();
LoginResult lres = screen.login(username, password);

Content content = screen.getSchema();  
ArrayOfFilter filters = new ArrayOfFilter();

ArrayOfCommand commands = new ArrayOfCommand();

commands.getCommand().add(content.getReportResults().getHtmlContent());
ArrayOfArrayOfString result = screen.export(commands, filters, 0, true, true);
List<ArrayOfString> lines = result.getArrayOfString();

如果我在没有参数的情况下调用报告,我会收到以下错误:

javax.xml.ws.soap.SOAPFaultException: 
System.Web.Services.Protocols.SoapException: 
Server was unable to process request. --> PX.Data.PXViewDoesNotExitException: 
Error: The view Parameters doesn't exist.

我更改了我的代码以匹配答案中的 C# 代码:

              Content content = screen.getSchema();  
              ArrayOfFilter filters = new ArrayOfFilter();

              Value fromPeriod = new Value();
              fromPeriod.setLinkedCommand(content.getParameters().getFromPeriod());
              fromPeriod.setValue("06-2018");

              Value toPeriod = new Value();
              toPeriod.setLinkedCommand(content.getParameters().getToPeriod());
              toPeriod.setValue("06-2018");

              Value ledger = new Value();
              ledger.setLinkedCommand(content.getParameters().getLedger());
              ledger.setValue("ACTUAL");

              Value company = new Value();
              company.setLinkedCommand(content.getParameters().getCompany());
              company.setValue("PRODUCTS");

              Value branch = new Value();
              branch.setLinkedCommand(content.getParameters().getBranch());
              branch.setValue("PRODWHOLE");

              ArrayOfCommand commands = new ArrayOfCommand();
              commands.getCommand().add(content.getReportResults().getHtmlContent());
              commands.getCommand().add(fromPeriod);
              commands.getCommand().add(toPeriod);
              commands.getCommand().add(ledger);
              commands.getCommand().add(company);
              commands.getCommand().add(branch);

              ArrayOfArrayOfString result = screen.export(commands, filters, 0, true, true);

我现在收到一个新错误:

javax.xml.ws.soap.SOAPFaultException:System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.ArgumentNullException:值不能为空。 参数名称:key 在 System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument 参数) 在 System.Collections.Generic.Dictionary2.FindEntry(TKey key) at PX.Data.PXViewCollection.get_Item(String key) at PX.Api.SyImportProcessor.ExportTableHelper..ctor(SyExportContext context, Boolean submit) at PX.Api.ScreenUtils.a(String A_0, Command[] A_1, Int32 A_2, Int32 A_3, Boolean A_4, Boolean A_5, Dictionary2 A_6、OptimizedExportProviderBuilderForScreenBasedApi A_7、布尔 A_8、PXViewDescription[] A_9、ScreenInfo A_10、HashSet1 A_11, Dictionary2 A_12、SyExportContext A_13) 在 PX.Api.ScreenUtils.ExportInternal(字符串 screenId,Command[] 命令,Filter[] 过滤器,Int32 startRow,Int32 topCount,布尔 includeHeaders,布尔 breakOnError,PXGraph 图,布尔 bindGuids,布尔移动,布尔 isSelector,字符串 forcePrimaryView,字符串bindContainer, Dictionary2 sorts, String guidViewName, OptimizedExportProviderBuilderForScreenBasedApi buildOptimizedExportProviderDelegate, Func3 serializationDelegate) 在 PX.Api.Services.ScreenService.Export(字符串 id,Command[] 命令,Filter[] 过滤器,Int32 startRow,Int32 topCount,布尔 includeHeaders,布尔 breakOnError,布尔 bindGuids,布尔移动,布尔 isSelector,字符串 forcePrimaryView,PXGraph forceGraph , 字符串 bindContainer, Dictionary2 sorts, String guidViewName, Boolean disableOptimizedExport) at PX.Api.Soap.Screen.ScreenGate.Export(Command[] commands, Filter[] filters, Int32 topCount, Boolean includeHeaders, Boolean breakOnError) --- End of inner exception stack trace --- at org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195) ~[cxf-rt-frontend-jaxws-3.3.2.jar:3.3.2] at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145) ~[cxf-rt-frontend-jaxws-3.3.2.jar:3.3.2] at com.sun.proxy.$Proxy45.export(Unknown Source) ~[?:?] at com.appcomputing.be.acdata.acumatica.gl633000.GL633000.getReport(GL633000.java:89) [classes/:?] at com.appcomputing.be.acdata.acumatica.gl633000.GL633000.main(GL633000.java:115) [classes/:?] Caused by: org.apache.cxf.binding.soap.SoapFault: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null. Parameter name: key at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Collections.Generic.Dictionary2.FindEntry(TKey key) 在 PX.Data.PXViewCollection.get_Item(字符串键) 在 PX.Api.SyImportProcessor.ExportTableHelper..ctor(SyExportContext 上下文,布尔提交) 在 PX.Api.ScreenUtils.a(String A_0, Command[] A_1, Int32 A_2, Int32 A_3, Boolean A_4, Boolean A_5, Dictionary2 A_6, OptimizedExportProviderBuilderForScreenBasedApi A_7, Boolean A_8, PXViewDescription[] A_9, ScreenInfo A_10, HashSet1 A_11, Dictionary2 A_12, SyExportContext A_13) at PX.Api.ScreenUtils.ExportInternal(String screenId, Command[] commands, Filter[] filters, Int32 startRow, Int32 topCount, Boolean includeHeaders, Boolean breakOnError, PXGraph graph, Boolean bindGuids, Boolean mobile, Boolean isSelector, String forcePrimaryView, String bindContainer, Dictionary2 sorts, String guidViewName, OptimizedExportProviderBuilderForScreenBasedApi buildOptimizedExportProviderDelegate, Func 3 serializationDelegate) at PX.Api.Services.ScreenService.Export(String id, Command[] commands, Filter[] filters, Int32 startRow, Int32 topCount, Boolean includeHeaders, Boolean breakOnError, Boolean bindGuids, Boolean mobile, Boolean isSelector, String forcePrimaryView, PXGraph forceGraph, String bindContainer, Dictionary2 排序,字符串 guidViewName,布尔型 disableOptimizedExport) 在 PX.Api.Soap.Screen.ScreenGate.Export(Command[] commands, Filter[] filters, Int32 topCount, Boolean includeHeaders, Boolean breakOnError) --- 内部异常堆栈跟踪结束 ---

在将 screen.export(...) 替换为 screen.submit(commands) 之后,我终于让 web 服务工作了。但结果只有一个长的二进制(非文本)字符串。

如果有人可以帮助解释这个字符串(我们需要报告中的数据值),那将非常有用

【问题讨论】:

    标签: java soap acumatica


    【解决方案1】:

    此代码示例使用 C# 编写,适用于 pdf 文件,但我认为它可能有用。这几乎是不言自明的:

    //Getting the printable version of an invoice
    //on the Invoice & Memo form (S0643000)
    public static void GetPrintableInvoice()
    {
        //Invoice data
        string docType = "Invoice";
        string invoiceNbr = "INV000045";
        using
        (
        //Connect to the web services and log in to Acumatica ERP
        Screen context = WebServiceConnector.InitializeWebService())
        {
            try
            {
                //Get the schema of the Invoice & Memo form (S0643000)
                SO643000Content invoiceFormSchema = context.SO643000GetSchema();
                //Specify the needed invoice and get a PDF version of it
                var commands = new Command[]
                {
                    new Value
                    {
                        Value = docType,
                        LinkedCommand = invoiceFormSchema.Parameters.DocumentType
                    },
                    new Value
                    {
                        Value = invoiceNbr,
                        LinkedCommand = invoiceFormSchema.Parameters.ReferenceNumber
                    },
                    invoiceFormSchema.ReportResults.PdfContent
                };
                //Submit the commands to the form
                SO643000Content[] pdfInvoice = context.SO643000Submit(commands);
                //Save the result in a PDF file
                if (pdfInvoice != null && pdfInvoice.Length > 0)
                {
                    File.WriteAllBytes(string.Format(@"Invoice_{0}.pdf", invoiceNbr),
                    Convert.FromBase64String(pdfInvoice[0].ReportResults.PdfContent.Value));
                }
            }
            finally
            {
                //Log out from Acumatica ERP
                context.Logout();
            }
        }
    }
    

    所以,在你的情况下应该是这样的:

    screen = service.getScreenSoap();
    LoginResult lres = screen.login(username, password);
    
    Content content = screen.getSchema();  
    ArrayOfFilter filters = new ArrayOfFilter();
    
    ArrayOfCommand commands = new ArrayOfCommand();
    
    commands.getCommand().add(content.getValue("ParamValue",content.Parameters.fromPeriod));
    commands.getCommand().add(content.getReportResults().getHtmlContent());
    ArrayOfArrayOfString result = screen.export(commands, filters, 0, true, true);
    List<ArrayOfString> lines = result.getArrayOfString();
    

    基本上,设置参数值的方式与更新记录时设置字段值的方式相同

    【讨论】:

    • 我更改了我的代码以匹配上面的 C# 代码,现在我在上面发布了一个新错误
    猜你喜欢
    • 2019-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多