gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 09:34:10 24 4
gpt4 key购买 nike

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

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

我在 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.Dictionary 2.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, Dictionary
2 A_6, OptimizedExportProviderBuilderForScreenBasedApi A_7, Boolean A_8, PXViewDescription[] A_9, ScreenInfo A_10, HashSet 1 A_11, Dictionary 2 A_12,SyExportContext A_13)
在 PX.Api.ScreenUtils.ExportInternal(字符串 screenId,Command[] 命令,Filter[] 过滤器,Int32 startRow,Int32 topCount, boolean includeHeaders, boolean breakOnError,PXGraph 图, boolean bindGuids, boolean 移动, boolean isSelector,字符串 forcePrimaryView,字符串bindContainer, Dictionary 2 sorts, String guidViewName, OptimizedExportProviderBuilderForScreenBasedApi buildOptimizedExportProviderDelegate, Func 3 序列化委托(delegate))
在 PX.Api.Services.ScreenService.Export(字符串 id,Command[] 命令,Filter[] 过滤器,Int32 startRow,Int32 topCount, boolean includeHeaders, boolean breakOnError, boolean bindGuids, boolean 移动, boolean isSelector,字符串 forcePrimaryView,PXGraph forceGraph , String bindContainer, Dictionary 2 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.Dictionary
2.FindEntry(TKey key)
在 PX.Data.PXViewCollection.get_Item(字符串键)
在 PX.Api.SyImportProcessor.ExportTableHelper..ctor(SyExportContext 上下文, boolean 提交)
在 PX.Api.ScreenUtils.a(String A_0, Command[] A_1, Int32 A_2, Int32 A_3, Boolean A_4, Boolean A_5, Dictionary 2 A_6, OptimizedExportProviderBuilderForScreenBasedApi A_7, Boolean A_8, PXViewDescription[] A_9, ScreenInfo A_10, HashSet 1 A_11, Dictionary 2 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, Dictionary
2 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, Dictionary
2 种,字符串 guidViewName, boolean 型 disableOptimizedExport)
在 PX.Api.Soap.Screen.ScreenGate.Export(Command[] commands, Filter[] filters, Int32 topCount, Boolean includeHeaders, Boolean breakOnError)
--- 内部异常堆栈跟踪结束 ---

在用 screen.submit(commands) 替换 screen.export(...) 后,我终于让 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();

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

关于java - 在java中使用基于屏幕的soap api调用Acumatica报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56715491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com