使用Acumatica SOAP创建账单会导致错误“;System.ArgumentNullException:值不能为空";
您好,谢谢您的阅读 我正在尝试使用SOAP创建一个账单。为了指定特定的非库存项目,我扩展了端点并将字段InventoryID InventoryID包含到BillDetail对象中。然后我更新了WSDL文件。出口票据现在运作良好。但创建失败,字段中没有任何信息 代码如下:使用Acumatica SOAP创建账单会导致错误“;System.ArgumentNullException:值不能为空";,acumatica,Acumatica,您好,谢谢您的阅读 我正在尝试使用SOAP创建一个账单。为了指定特定的非库存项目,我扩展了端点并将字段InventoryID InventoryID包含到BillDetail对象中。然后我更新了WSDL文件。出口票据现在运作良好。但创建失败,字段中没有任何信息 代码如下: string lcSQL, lcErrMsg, lcStage = "Start"; AcmtIntegrator.AcumaticaWSDL.Defaul
string lcSQL, lcErrMsg, lcStage = "Start";
AcmtIntegrator.AcumaticaWSDL.DefaultSoapClient soapClient = null;
soapClient = new AcmtIntegrator.AcumaticaWSDL.DefaultSoapClient(clsACMT.CreateBinding(clsGlobals.gcAcmtURL),
clsACMT.CreateEndpoint(clsGlobals.gcAcmtURL, clsGlobals.gcAcmtEndPoint, clsGlobals.gcAcmtVersion));
string lcBranch, lcLocationID;
lcBranch = mdlGU.GetSystemOption("ACMTEXTRACT", "CreditMemo", "Branch", "YOGIFON");
lcLocationID = mdlGU.GetSystemOption("ACMTEXTRACT", "CreditMemo", "LocationID", "");
// Bill Level:
lcBranch = "SOFT";
string docType = "Bill";
string lcVendorCd = "EP00000001";
string lcVendorRef = "VendorRef - 2";
decimal lnBillAmt = 1000;
string lcDocTxnDate = "20201005", lcDocDueDate = "20201104";
string lcCashAccount = "102000SOFT";
string lcBillDesc = "bill Desc 2";
string lcRefNo = "RefNo";
string lcTerms = "30D";
string lcPostPeriod = "102020";
int lnLineCount = 0;
lcSQL = "select count(*) from tblCBInputCMItemLine where CMHdrID = " + Convert.ToString(1);
lnLineCount = mdlGU.GetSQLScalar(lcSQL, 0);
lnLineCount = 1;
// Bill Line
decimal lnLineExtAmt = 1000, lnUnitCost = 0, lnLineQty = 0;
string lcLinePOOrderNbr = "", lcLinePOOrderType = "", lcLineDesc = "Line Desc", lcLineTranDesc = "Tran Desc";
string lcLineAccount, lcLineSubAccount, lcUoM, lcLineItemInvID, lcLineProject = "", lcLineProjectTask = "";
string lcItemAcmtGuid = "61594ca1-0d6b-e411-a445-e06995c86014";
//
BillDetail[] loBillDetails;
loBillDetails = new BillDetail[lnLineCount];
lcSQL = "select AcmtInventoryID from stdAcmtNonStockItem where AcmtGuid = '" + Convert.ToString(lcItemAcmtGuid) + "'";
lcLineItemInvID = mdlGU.GetSQLScalar(lcSQL, "");
lcSQL = "select ItemDesc from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcLineDesc = mdlGU.GetSQLScalar(lcSQL, "");
lcSQL = "select ExpenseAccount from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcLineAccount = mdlGU.GetSQLScalar(lcSQL, "215000");
lcSQL = "select ExpenseSubAccount from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcLineSubAccount = mdlGU.GetSQLScalar(lcSQL, "");
lcSQL = "select BaseUnit from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcUoM = mdlGU.GetSQLScalar(lcSQL, "");
loBillDetails[0] = new BillDetail
{
Branch = new StringValue { Value = lcBranch },
Amount = new DecimalValue { Value = lnLineExtAmt },
ExtendedCost = new DecimalValue { Value = lnLineExtAmt },
UnitCost = new DecimalValue { Value = lnUnitCost },
Qty = new DecimalValue { Value = lnLineQty },
TransactionDescription = new StringValue { Value = lcLineTranDesc },
Description = new StringValue { Value = lcLineDesc },
POOrderNbr = new StringValue { Value = lcLinePOOrderNbr },
POOrderType = new StringValue { Value = lcLinePOOrderType },
Account = new StringValue { Value = lcLineAccount },
Subaccount = new StringValue { Value = lcLineSubAccount },
// InventoryID = new StringValue { Value = lcLineItemInvID },
UOM = new StringValue { Value = lcUoM },
//Project = new StringValue { Value = lcLineProject },
//ProjectTask = new StringValue { Value = lcLineProjectTask }
};
Bill loBill = new Bill
{
ReturnBehavior = ReturnBehavior.OnlySpecified,
// Type = new StringValue { Value = docType },
// ReferenceNbr = new StringReturn { Value = lcRefNo },
Type = new StringValue (),
ReferenceNbr = new StringReturn (),
Status = new StringReturn(),
Vendor = new StringValue { Value = lcVendorCd },
VendorRef = new StringValue { Value = lcVendorRef },
PostPeriod = new StringValue { Value = lcPostPeriod },
Terms = new StringValue { Value = lcTerms },
Hold = new BooleanValue { Value = false },
Amount = new DecimalValue { Value = lnBillAmt },
Balance = new DecimalValue { Value = lnBillAmt },
CashAccount = new StringValue { Value = lcCashAccount },
Description = new StringValue { Value = lcBillDesc },
ApprovedForPayment = new BooleanValue { Value = true },
BranchID = new StringValue { Value = lcBranch },
Details = loBillDetails,
};
// LocationID is optional
if (lcLocationID != "")
{
loBill.LocationID = new StringValue { Value = lcLocationID };
}
if (lcDocTxnDate != "")
{
loBill.Date = new DateTimeValue
{
Value = new DateTime(Convert.ToInt32(mdlGU.MyLeft(lcDocTxnDate, 4)),
Convert.ToInt32(lcDocTxnDate.Substring(4, 2)),
Convert.ToInt32(lcDocTxnDate.Substring(6, 2)))
};
loBill.DueDate = new DateTimeValue
{
Value = new DateTime(Convert.ToInt32(mdlGU.MyLeft(lcDocDueDate, 4)),
Convert.ToInt32(lcDocDueDate.Substring(4, 2)),
Convert.ToInt32(lcDocDueDate.Substring(6, 2)))
};
};
//Create a Bill
Bill newBill = new Bill();
try
{
newBill = (Bill)soapClient.Put(loBill);
//lcTxnID = newInvoice.ID.ToString();
//lnPaidAmtCurr = newInvoice.Amount.Value.Value * lnAmtMultiplier;
//lcDocRefNumber = newInvoice.ReferenceNbr.Value;
// User to be "and CMNumberCurr = ''" Not sure why.
// lcSQL = String.Format("Update tblCBInputCMHdr set ProcessingStatusID = 5, CMNumberCurr = '{0}', DocRefNumber = '{0}', TxnID = '{2}', PaidAmtCurr = {3} where CMHdrId = {1} and CMNumberCurr = ''", lcRefNumber, lnCMHdrID, lcTxnID, lnPaidAmtCurr);
//lcSQL = String.Format("Update tblCBInputCMHdr set ProcessingStatusID = 5, CMNumberCurr = '{0}', DocRefNumber = '{4}', TxnID = '{2}', PaidAmtCurr = {3} where CMHdrId = {1}", lcRefNumber, lnCMHdrID, lcTxnID, lnPaidAmtCurr, lcDocRefNumber);
//mdlGU.SqlClientExecuteSQL(lcSQL, "MakeCreditMemo", lcSQL, lcErrMsg);
//mdlGU.WriteAppLog("Make CM", "HeaderID = " + Convert.ToString(lnCMHdrID), "Making CM Lines", false);
//mdlGU.WriteAppLog("Make CreditMemo", "HeaderID = " + Convert.ToString(lnCMHdrID), "Set Status in tblCBInputCMHdr", false);
}
catch (Exception ex)
{
lcErrMsg = ex.Message.Replace("'", "").Substring(0, 900);
}
完整的错误消息显示:System.ArgumentNullException:值不能为空。\n参数名称:Microsoft.Data.Edm.EdmUtil.CheckArgumentNull[T](T值,字符串参数名称)\n Microsoft.Data.Edm.ExtensionMethods.EntityContainers(IEdmModel模型)\n PX.Api.ContractBased.Edm.Helpers.GetEntityType(IEdmModel model,String objectName)\n位于PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(String expectedEntityType)\n位于PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(XmlReader reader,String localname,String expectedNamespace,String expectedEntityType)\n位于PX.Api.ContractBased.Soap.SoapMessageTransformerBase.BindParameters(XmlReader requestReader,MethodInfo MethodInfo,元组`2[]ParameterInfo)\n位于PX.Api.ContractBased.Soap.WebApiSoapController.Post(ISoapSystemContract systemContract,XmlReader requestReader,String serviceNamespace,String internalNamespace,MethodInfo method,Fun)
引发异常:mscorlib.dll中的“System.ServiceModel.FaultException”
我正在使用Acumatica 2019的本地版本和培训租户MyStore。我以管理员身份登录
任何帮助都将不胜感激
问候,,
Alexander登录名丢失
soapClient.Login(clsGlobals.gcAcmtUserName, clsGlobals.gcAcmtPwd, clsGlobals.gcAcmtCompany, clsGlobals.gcAcmtBranch, null);
登录名丢失
soapClient.Login(clsGlobals.gcAcmtUserName, clsGlobals.gcAcmtPwd, clsGlobals.gcAcmtCompany, clsGlobals.gcAcmtBranch, null);
即使在默认端点上创建账单时也会发生相同的错误。即使在默认端点上创建账单时也会发生相同的错误。