D
D
ddelphknn2014-11-22 11:56:16
PHP
ddelphknn, 2014-11-22 11:56:16

Pass parameter from PHP to 1C web service?

There is a web service in 1C, it has a method that should take 2 parameters.
I'm trying to call a method in php, but I'm doing something wrong with the parameters
Attempt #1
PHP code:

$SoapClient1C = new SoapClient("http://test.1c/WEB/ws/webservice?wsdl");
$BeginDate = date_create('2000-01-01');
$EndDate = date_create('2014-12-12'); 
$List = $SoapClient1C->getDDSFact($BeginDate,$EndDate);

Gives an error message:
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'BDate' property in C:\xampp\htdocs\site.dd\index.php:149 Stack trace: #0 C:\xampp\ htdocs\site.dd\index.php(149): SoapClient->__call('getDDSFact', Array) #1 C:\xampp\htdocs\site.dd\index.php(149): SoapClient->getDDSFact(Object (DateTime), Object(DateTime)) #2 {main} thrown in C:\xampp\htdocs\site.dd\index.php on line 149

Attempt #2
PHP code:
$SoapClient1C = new SoapClient("http://test.1c/WEB/ws/webservice?wsdl");
$BeginDate = date_create('2000-01-01');
$EndDate = date_create('2014-12-12'); 
$List = $SoapClient1C->getDDSFact(array("BDate" => $BeginDate, "EDate" => $EndDate));

Mistake:
Fatal error: Uncaught SoapFault exception: [soap:Client] Unknown error. XDTO data validation failed: Value: '' does not match simple type: { http://www.w3.org/2001/XMLSchema}dateTime due to: XDTO data validation failed: Value: '' does not match simple type: { http: //www.w3.org/2001/XMLSchema}dateTime in C:\xampp\htdocs\site.dd\index.php:149 Stack trace: #0 C:\xampp\htdocs\site.dd\index.php( 149): SoapClient->__call('getDDSFact', Array) #1 C:\xampp\htdocs\site.dd\index.php(149): SoapClient->getDDSFact(Array) #2 {main} thrown in C: \xampp\htdocs\site.dd\index.php on line 149

Thanks in advance for any help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Senkevich, 2014-11-22
@ddelphknn

You are passing dates as a DateTime object, and the method is likely expecting them to be a string. Try this option:

$SoapClient1C = new SoapClient("http://test.1c/WEB/ws/webservice?wsdl");
$List = $SoapClient1C->getDDSFact(array("BDate" => '2000-01-01', "EDate" => '2014-12-12'));

If it does not work, then look in the documentation in which format this method accepts dates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question