使用php的Dolibarr soap web服务使用

时间:2015-08-26 15:32:13

标签: php web-services soap wsdl

我正在尝试使用带有php的Dolibarr soap web服务

Dolibarr web service

这就是我现在所得到的:

$url = "http://localhost/seko/dollibar/dolibarr-3.7.1/htdocs/webservices/server_invoice.php?wsdl";
$client = new SoapClient($url);
$authentication = array(
                    "dolibarrkey" => "xxxxx",
                    "sourceapplication" => "",
                    "login" => "xxxx",
                    "password" => "xxxxxx",
                    "entity" => "1"
                  );

                  $line = array(
                              "id" => "57",
                              "type" => 0,
                              "desc" => "SEKO",
                              "vat_rate" => 16.000,
                              "qty" => 03,
                              "unitprice" => 10500.00000000,
                              "total_net" => 10500.0000000,
                              "total_vat" => 1680.00000000,
                              "total" => 12180.0000000,
                              "date_start" => "",
                              "date_end" => "",
                              "payment_mode_id" => "efectivo",
                              "product_id" => 1,
                              "product_ref" => "",
                              "product_label" => "",
                              "product_desc" => ""
                          );

                 $invoice = array(
                              "id" => "57", 
                              "ref" => "0007", 
                              "ref_ext" => "test",
                              "thirdparty_id" => 3,
                              "fk_user_author" => "1",
                              "fk_user_valid" => "1",
                              "date" => date("Y-m-d"),
                              "date_due" => date("Y-m-d"),
                              "date_creation" => date("Y-m-d h:i:sa"),
                              "date_validation" => date("Y-m-d h:i:sa"),
                              "date_modification" => "",
                              "type" => 0,
                              "total_net" => 10500.00000000,
                              "total_vat" => 1680.00000000,
                              "total" => 12180.0000000,
                              "note_private" => "",
                              "note_public" => "",
                              "status" => 2,
                              "close_code" => "",
                              "close_note" => "",
                              "project_id" => "",
                              "lines" => $lines

                           );

        $res = $client->createInvoice($authentication, $invoice);
        var_dump($res);

我收到以下错误:

  

遇到未捕获的异常

     

输入:SoapFault

     

消息:看起来我们没有XML文档

当我使用服务的getInvoice方法时,它可以正常工作。但不是creatInvoice方法。我确定问题出在我的$line数组上,但我不知道如何修复它。

1 个答案:

答案 0 :(得分:0)

根据XML文档(在您的webbrowser中打开此http://localhost/seko/dollibar/dolibarr-3.7.1/htdocs/webservices/server_invoice.php?wsdl)  请注意,您需要从 $ line 数组中删除“ payment_mode_id ”字段并将其移至您的 $ invoice 数组

像这样:

                  $line = array(
                          "id" => "57",
                          "type" => 0,
                          "desc" => "SEKO",
                          "vat_rate" => 16.000,
                          "qty" => 03,
                          "unitprice" => 10500.00000000,
                          "total_net" => 10500.0000000,
                          "total_vat" => 1680.00000000,
                          "total" => 12180.0000000,
                          "date_start" => "",
                          "date_end" => "",
                          "product_id" => 1,
                          "product_ref" => "",
                          "product_label" => "",
                          "product_desc" => ""
                      );


                 $invoice = array(
                          "id" => "57", 
                          "ref" => "0007", 
                          "ref_ext" => "test",
                          "thirdparty_id" => 3,
                          "fk_user_author" => "1",
                          "fk_user_valid" => "1",
                          "date" => date("Y-m-d"),
                          "date_due" => date("Y-m-d"),
                          "date_creation" => date("Y-m-d h:i:sa"),
                          "date_validation" => date("Y-m-d h:i:sa"),
                          "date_modification" => "",
                          "payment_mode_id" => "efectivo",
                          "type" => 0,
                          "total_net" => 10500.00000000,
                          "total_vat" => 1680.00000000,
                          "total" => 12180.0000000,
                          "note_private" => "",
                          "note_public" => "",
                          "status" => 2,
                          "close_code" => "",
                          "close_note" => "",
                          "project_id" => "",
                          "lines" => $lines
                       );

希望得到帮助

此致