在java中使用基于屏幕的soap api调用Acumatica报告

在java中使用基于屏幕的soap api调用Acumatica报告,java,soap,acumatica,Java,Soap,Acumatica,我正在使用Java通过基于屏幕的SOUP Web服务(使用ApacheCxf生成的代码)获取Acumatica报告。我感兴趣的报告是《金融》中的《会计期间交易》。我知道如何向web服务传递命令以指定返回的结果,但不知道如何传递参数 我要传递的参数是从期间,到期间,分类帐,从帐户和到帐户。我是通过过滤器还是其他方式传递参数?如果作为过滤器,如何创建过滤器对象 我在Java中找不到任何调用Acumatica SOAP Web服务的示例,因此非常感谢您的帮助 我更改了代码以匹配答案中的C代码:

我正在使用Java通过基于屏幕的SOUP Web服务(使用
ApacheCxf
生成的代码)获取Acumatica报告。我感兴趣的报告是《金融》中的《会计期间交易》。我知道如何向web服务传递命令以指定返回的结果,但不知道如何传递参数

我要传递的参数是
从期间
到期间
分类帐
从帐户
到帐户
。我是通过过滤器还是其他方式传递参数?如果作为过滤器,如何创建过滤器对象

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


我更改了代码以匹配答案中的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:值不能为null。 参数名称:key 在System.ThrowHelper.ThrowArgumentNullException处(参数异常) 在System.Collections.Generic.Dictionary
2.FindEntry(TKey)
在PX.Data.PXViewCollection.get_项(字符串键)
位于PX.Api.SyImportProcessor.ExportTableHelper..ctor(SyExportContext上下文,布尔提交)
在PX.Api.ScreenUtils.a(字符串a_0,命令[]a_1,Int32 a_2,Int32 a_3,布尔值a_4,布尔值a_5,字典
2 a_6,OptimizedExportProviderBuilderForScreenBasedApi a_7,布尔值a_8,PXViewDescription[]a_9,屏幕信息a_10,哈希集
1 a_11,字典
2 a_12,SyExportContext a_13) 在PX.Api.ScreenUtils.ExportInternal(字符串screenId,命令[]命令,过滤器[])过滤器、Int32 startRow、Int32 topCount、Boolean includeHeaders、Boolean BreakError、PXGraph图形、Boolean bindGuids、Boolean mobile、Boolean isSelector、String forcePrimaryView、String bindContainer、Dictionary
2排序、String guidViewName、OptimizedExportProviderBuilderForScreenBasedApi buildOptimizedExportProviderDelegate、Func
3序列化(代理) 在PX.Api.Services.ScreenService.Export(字符串id,命令[]命令,过滤器[]过滤器、Int32 startRow、Int32 topCount、Boolean includeHeaders、Boolean BreakError、Boolean bindGuids、Boolean mobile、Boolean isSelector、String forcePrimaryView、PXGraph forceGraph、String bindContainer、Dictionary
2排序、String guidViewName、Boolean disableOptimizedExport)
在PX.Api.Soap.Screen.ScreenGate.Export(命令[]命令,过滤器[]过滤器,Int32 topCount,布尔includeHeaders,布尔breakError)
---内部异常堆栈跟踪的结束---
在org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195)~[cxf-rt-frontend-jaxws-3.3.2.jar:3.3.2]
在org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)~[cxf-rt-frontend-jaxws-3.3.2.jar:3.3.2]
在com.sun.proxy.$Proxy45.export(未知源)~[?:?]
在com.appcomputing.be.acdata.acumatica.gl633000.gl633000.getReport(gl633000.java:89)[classes/:?]
在com.appcomputing.be.acdata.acumatica.gl633000.gl633000.main(gl633000.java:115)[classes/:?]
原因:org.apache.cxf.binding.soap.SoapFault:System.Web.Services.Protocols.SoapException:服务器无法处理请求。-->System.ArgumentNullException:值不能为null。
参数名称:key
在System.ThrowHelper.ThrowArgumentNullException处(参数异常)
位于System.Collections.Generic.Dictionary
2.FindEntry(TKey) 在PX.Data.PXViewCollection.get_项(字符串键) 位于PX.Api.SyImportProcessor.ExportTableHelper..ctor(SyExportContext上下文,布尔提交) 在PX.Api.ScreenUtils.a(字符串a_0,命令[]a_1,Int32 a_2,Int32 a_3,布尔值a_4,布尔值a_5,字典
2 a_6,OptimizedExportProviderBuilderForScreenBasedApi a_7,布尔值a_8,PXViewDescription[]a_9,屏幕信息a_10,哈希集
1 a_11,字典
2 a_12,SyExportContext a_13)
在PX.Api.ScreenUtils.ExportInternal(字符串screenId,命令[]命令,过滤器[])过滤器、Int32 startRow、Int32 topCount、Boolean includeHeaders、Boolean BreakError、PXGraph图形、Boolean bindGuids、Boolean mobile、Boolean isSelector、String forcePrimaryView、String bindContainer、Dictionary
2排序、String guidViewName、OptimizedExportProviderBuilderForScreenBasedApi buildOptimizedExportProviderDelegate、Func
3序列化(代理)
在PX.Api.Services.ScreenService.Export(字符串id,命令[]命令,过滤器[]过滤器、Int32 startRow、Int32 topCount、Boolean includeHeaders、Boolean BreakError、Boolean bindGuids、Boolean mobile、Boolean isSelector、String forcePrimaryView、PXGraph forceGraph、String bindContainer、Dictionary
2排序、String guidViewName、Boolean disableOptimizedExport) 在PX.Api.Soap.Screen.ScreenGate.Export(命令[]命令,过滤器[]过滤器,Int32 topCount,布尔includeHeaders,布尔breakError) ---内部异常堆栈跟踪的结束---

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

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

这个代码示例是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();
screen=service.getScreenSoap();
LoginResult lres=屏幕。登录(用户名、密码);
Content=screen.getSchema();
ArrayOfFilter过滤器=新的ArrayOfFilter();
ArrayOfCommand commands=新的ArrayOfCommand();
commands.getCommand().add(content.getValue(“ParamValue”,content.Parameters.fromPeriod));
commands.getCommand().add(content.getReportResults().getHtmlContent());
ArrayOfArrayOfString结果=screen.export(命令、过滤器、0、true、true);
列表行=resu
//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();