Как экспортировать счет или текущую выписку с помощью SOAP API Acumatica через PHP?

Как экспортировать счет или текущую выписку с помощью SOAP API Acumatica через PHP?

Я могу генерировать классы-заглушки SOAP PHP, используя https://www.wsdltophp.com/

Большинство примеров, которые я нашел, используют .Net

WSDL, который предоставил мне мой клиент:
http://erp.triode.co.nz/pmsdb/Soap/INEXPORT.asmx?WSDL

Из того, что я вижу, кажется, что Acumatica имеет несколько WSDL для разных процедур. Если бы кто-то мог дать мне точку в правильном направлении, это было бы здорово. Я могу аутентифицироваться с помощью конечной точки Acumatica, я просто застрял в том, с чего начать с этого варианта использования.

***ОБНОВИТЬ****

Хорошо, теперь я использую вспомогательные файлы 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();

?>

Получение ошибки:

Неустранимая ошибка: необработанное исключение SoapFault: [soap: Server] System.Web.Services.Protocols.SoapException: серверу не удалось обработать запрос. —> System.NullReferenceException: ссылка на объект не установлена ​​для экземпляра объекта. в PX.Api.SyImportContext.ParseCommand (SyCommand cmd) в PX.Api.SyExportContext.a (SYMappingField A_0) в System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Collections.Generic.List1..ctor (IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 источник) в PX.Api.SyExportContext..ctor (отображение SYMapping, IEnumerable1 fields, String[] providerFields, Dictionary2 viewFilters, логическое значение breakOnError, запуск Int32, число Int32, LinkedSelectorViews selectorViews, String rowFilterField) в PX.Api.ScreenUtils.ExportInternal (строковый screenId, команды Command [], фильтры Filter [], int32 startRow, Int32 topCount, логическое включение HH). breakOnError, PXGraph graph, Boolean bindGuids, Boolean mobile, Boolean isSelector, String forcePrima в /vagrant_www/triode-soap/AR402000/Screen.php в строке 549

Это метод .Net, который я пытаюсь реконструировать:

Пример 4.3.4. Получение списка счетов клиента
Этот пример, который предоставляется только для справки, показывает, как получить список счетов для клиента
(по идентификатору клиента) в форме «Сведения о клиенте» (AR402000; Финансы> Дебиторская задолженность> Работа
Площадь> Изучить).

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();
}
}
}
}

ОБНОВИТЬ

Обновленный скрипт и теперь получающий пустой ответ от конечной точки 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();

?>

SOAP XML ЗАПРОС

<?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>

ОТВЕТ НА КОНЕЧНУЮ ТОЧКУ

<?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>

5

Решение

Как автор wsdltophp.com, я настоятельно советую вам использовать новую версию генератора с PackageGenerator, это должно работать лучше, чем с предыдущей версией. Если нет, не стесняйтесь связаться со мной по электронной почте.

1

Другие решения

Я не знаю, работали ли вы когда-нибудь, но вот пример, который я могу запустить, который тянет предметы инвентаря с «1» в названии. Надеюсь, это полезно.

//Create a Filter with which we'll see if our inventory item is already present
$field = new Field();
$field->FieldName = $schema->StockItemSummary->InventoryID->FieldName;
$field->ObjectName = $schema->StockItemSummary->InventoryID->ObjectName;
$condition = FilterCondition::Contain;
//Search String
$string = "1";
$filter = $client->PrepareSimpleFilter($field,$condition,$string);

//Create an Export command that will contain fields for return, various options, and our filter array
$export = new Export();
$export->commands = array(
$schema->StockItemSummary->InventoryID,
$schema->StockItemSummary->Description
);
$export->topCount = 15;
$export->includeHeaders = false;
$export->breakOnError = false;
$export->filters = array(
$filter
);
0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector