如何通过PHP使用Acumatica的SOAP API导出发票或当前语句?

Jer*_*eys 6 php soap acumatica

如何通过PHP使用Acumatica的SOAP API导出发票或当前语句?

我可以使用https://www.wsdltophp.com/生成SOAP PHP存根类

我发现的大多数例子都使用.Net

我的客户提供给我的WSDL是:http://erp.triode.co.nz/pmsdb/Soap/INEXPORT.asmx? WSDL

从我所看到的,似乎Acumatica有不同程序的多个WSDL.如果有人能给我一个指向正确方向的点,那就太好了.我可以使用Acumatica端点进行身份验证,我只是对这个用例从哪里开始陷入困境.

***UPDATE****

好的我现在正在使用Acumatica PHP帮助文件,这些文件非常有用,但不幸的是再次陷入困境,试图导出一个客户的发票列表:

<?php
ini_set('memory_limit','512M');
ini_set('display_errors',true);
error_reporting(-1);

require_once('AcumaticaGate.php');

//$wsdl = "http://erp.triode.co.nz/pmsdb/Soap/AR402000.asmx?WSDL";
// $client = new AcumaticaGate('<user_login>', '<user_password>', '<folder_name>','http://<computer>/<website>');

//Can't provide credentials for security reasons unfortunately
$un = ""
$pw = ""; 

$client = new AcumaticaGate($un, $pw, 'AR402000','http://erp.triode.co.nz/pmsdb');

$customer_id = "DAR";
$doctype = "Invoice";

$selection = $client->Schema->GetSchemaResult->Selection;
$customer = $selection->Customer = $customer_id;
$all_docs = $selection->ShowAllDocuments = true;
$unreleased = $selection->IncludeUnreleasedDocuments = true;
$type_doc = $client->Schema->GetSchemaResult->Documents->TypeDisplayDocType;

// FILTERS
$filters = array();

array_push($filters,
               $client->PrepareSimpleFilter(clone $type_doc, FilterCondition::Equals, $doctype));


$export_param = new Export();
$export_param->commands         = array($customer, $all_docs, $unreleased);
$export_param->filters                   = $filters;
$export_param->breakOnError    = true
$export_param->includeHeaders = false;
$export_param->topCount            = 0;

$export = $client->Client->Export($export_param);

echo "<pre>";
print_r($export);
echo "</pre>";

// echo $client->Client->__getLastRequest();

?>
Run Code Online (Sandbox Code Playgroud)

得到错误:

致命错误:未捕获的SoapFault异常:[soap:Server] System.Web.Services.Protocols.SoapException:服务器无法处理请求.---> System.NullReferenceException:对象引用未设置为对象的实例.位于PX.Api.SyExportContext..ctor的System.Linq.Enumerable.WhereSelectArrayIterator 2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable 1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)的PX.Api.SyExportContext.a(SYMappingField A_0)的PX.Api.SyImportContext.ParseCommand(SyCommand cmd)处. (SYMapping mapping,IEnumerable 1 fields, String[] providerFields, Dictionary2 viewFilters,Boolean breakOnError,Int32 start,Int32 count,LinkedSelectorViews selectorViews,String rowFilterField)at PX.Api.ScreenUtils.ExportInternal(String screenId,Command [] commands,Filter [] filters,Int32 startRow,Int32 topCount ,布尔includeHeaders,布尔breakOnError,PXGraph图,布尔bindGuids,布尔移动,布尔isSelector,第549行/vagrant_www/triode-soap/AR402000/Screen.php中的字符串forcePrima

这是我尝试逆向工程的.Net方法:

示例4.3.4:检索客户发票清单此示例(仅供参考)显示如何在"客户详细信息"表单(AR402000;财务>帐户)中获取客户发票清单(按客户ID)应收账款>工作区>探索).

class CustomerDetail
{
//Retrieving the list of invoices for the customer
//on the Customer Details form (AR402000)
public static void ExportInvoices()
{
    //Input data
    string customerID = "C000000003";
    string docType = "Invoice";
    using
   (
       //Connect to the web services and log in to Acumatica ERP
       Screen context = WebServiceConnector.InitializeWebService()
   )
  {
  try
  {
      //Get the schema of the Customer Details form (AR402000)
      AR402000Content customerDetailSchema = context.AR402000GetSchema();
      //Configure the list of commands
      var commands = new Command[]
      {
          //Select the documents from the inquiry
          new Value
          {
               Value = customerID,
               LinkedCommand = customerDetailSchema.Selection.Customer
          },
          new Value
          {
                Value = "True",
                LinkedCommand =      customerDetailSchema.Selection.ShowAllDocuments
          },
          new Value
         {
                Value = "True",
                LinkedCommand = customerDetailSchema.Selection.IncludeUnreleasedDocuments
         },

         //Get the values of the elements
        customerDetailSchema.Documents.TypeDisplayDocType,
        customerDetailSchema.Documents.ReferenceNbr,
        customerDetailSchema.Documents.Date,
        customerDetailSchema.Documents.Status
};

//Select for export only the orders of the needed customer
var filters = new Filter[]
{
new Filter
{
    Field = customerDetailSchema.Documents.TypeDisplayDocType,
    Condition = FilterCondition.Equals,
    Value = docType
}
};

//Export the records
var custormerInvoices = context.AR402000Export(commands, filters, 0, true, false);

//Save the export results to a CSV file
IOHelper.SaveToCSVFile(custormerInvoices,    string.Format(@"SOInvoices_Customer_{0}.csv", customerID));
}
finally
{
//Log out from Acumatica ERP
context.Logout();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)

UPDATE

更新了脚本,现在从API端点获得一个空响应,至少它不是一个错误,但仍然不幸,所以接受但不返回任何内容:

新代码

<?php
ini_set('memory_limit','512M');
ini_set('display_errors',true);
error_reporting(-1);

require_once('AcumaticaGate.php');

//$wsdl = "http://erp.triode.co.nz/pmsdb/Soap/INEXPORT.asmx?WSDL";

// $client = new AcumaticaGate('<user_login>', '<user_password>', '<folder_name>','http://<computer>/<website>');

$un = "";
$pw = "";

$client = new AcumaticaGate($un, $pw, 'AR402000','http://erp.triode.co.nz/pmsdb');

$customer_id = "3678";
$doctype = "Invoice";


$selection = $client->Schema->GetSchemaResult->Selection;
$customer = $selection->Customer;
$all_docs = $selection->ShowAllDocuments;
$unreleased = $selection->IncludeUnreleasedDocuments;
$type_doc = $client->Schema->GetSchemaResult->Documents->TypeDisplayDocType;

$command = array();
array_push($command, $client->PrepareValue($customer_id, $customer));
array_push($command, $client->PrepareValue('true', $all_docs));
array_push($command, $client->PrepareValue('true', $unreleased));


// FILTERS
$filters = array();


array_push($filters, $client->PrepareSimpleFilter(clone $type_doc, FilterCondition::Equals, $doctype));
array_push($filters, $client->PrepareSimpleFilter(clone $customer, FilterCondition::Equals, $customer_id));



$export_param = new Export();
$export_param->commands       = $command;
$export_param->filters        = $filters;
$export_param->breakOnError   = true;
$export_param->includeHeaders = false;
$export_param->topCount       = 0;

$export = $client->Client->Export($export_param);

// echo "<pre>";
// print_r($export);
// echo "</pre>";

echo $client->Client->__getLastRequest();

?>
Run Code Online (Sandbox Code Playgroud)

SOAP XML REQUEST

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-  ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.acumatica.com/typed/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
    <ns1:Export>
        <ns1:commands>
            <ns1:Command xsi:type="ns1:Value">
                <ns1:Value>3678</ns1:Value>
                <ns1:LinkedCommand xsi:type="ns1:Field">
                    <ns1:FieldName>CustomerID</ns1:FieldName>
                    <ns1:ObjectName>Filter</ns1:ObjectName>
                    <ns1:Value>Customer</ns1:Value>
                    <ns1:Commit>true</ns1:Commit>
                </ns1:LinkedCommand>
            </ns1:Command>
            <ns1:Command xsi:type="ns1:Value">
                <ns1:Value>true</ns1:Value>
                <ns1:LinkedCommand xsi:type="ns1:Field">
                    <ns1:FieldName>ShowAllDocs</ns1:FieldName>
                    <ns1:ObjectName>Filter</ns1:ObjectName>
                    <ns1:Value>ShowAllDocuments</ns1:Value>
                    <ns1:Commit>true</ns1:Commit>
                </ns1:LinkedCommand>
            </ns1:Command>
            <ns1:Command xsi:type="ns1:Value">
                <ns1:Value>true</ns1:Value>
                <ns1:LinkedCommand xsi:type="ns1:Field">
                    <ns1:FieldName>IncludeUnreleased</ns1:FieldName>
                    <ns1:ObjectName>Filter</ns1:ObjectName>
                    <ns1:Value>IncludeUnreleasedDocuments</ns1:Value>
                    <ns1:Commit>true</ns1:Commit>
                </ns1:LinkedCommand>
            </ns1:Command>
        </ns1:commands>
        <ns1:filters>
            <ns1:Filter>
                <ns1:Field>
                    <ns1:FieldName>DisplayDocType</ns1:FieldName>
                    <ns1:ObjectName>Documents</ns1:ObjectName>
                    <ns1:Value>TypeDisplayDocType</ns1:Value>
                </ns1:Field>
                <ns1:Condition>Equals</ns1:Condition>
                <ns1:Value xsi:type="xsd:string">Invoice</ns1:Value>
                <ns1:OpenBrackets>0</ns1:OpenBrackets>
                <ns1:CloseBrackets>0</ns1:CloseBrackets>
                <ns1:Operator>And</ns1:Operator>
            </ns1:Filter>
            <ns1:Filter>
                <ns1:Field>
                    <ns1:FieldName>CustomerID</ns1:FieldName>
                    <ns1:ObjectName>Filter</ns1:ObjectName>
                    <ns1:Value>Customer</ns1:Value>
                    <ns1:Commit>true</ns1:Commit>
                </ns1:Field>
                <ns1:Condition>Equals</ns1:Condition>
                <ns1:Value xsi:type="xsd:string">3678</ns1:Value>
                <ns1:OpenBrackets>0</ns1:OpenBrackets>
                <ns1:CloseBrackets>0</ns1:CloseBrackets>
                <ns1:Operator>And</ns1:Operator>
            </ns1:Filter>
        </ns1:filters>
        <ns1:topCount>0</ns1:topCount>
        <ns1:includeHeaders>false</ns1:includeHeaders>
        <ns1:breakOnError>true</ns1:breakOnError>
    </ns1:Export>
 </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

终点响应

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
        <ExportResponse xmlns="http://www.acumatica.com/typed/">
            <ExportResult />
        </ExportResponse>
    </soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

小智 1

作为 wsdltophp.com 的作者,我强烈建议您使用PackageGenerator中的新生成器版本,它应该比以前的版本工作得更好。如果没有,请随时通过电子邮件与我联系。