2015-08-26 48 views
0

我试图使用的Dolibarr SOAP的Web服务与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); 

我得到的以下错误:

An uncaught Exception was encountered

Type: SoapFault

Message: looks like we got no XML document

当我使用getInvoice方法的ser副工作正常。但不是creatInvoice方法。我确定问题出在我的$line阵列上,但我不知道如何解决它。

回答

0

根据XML文件(在你的网页浏览器打开此http://localhost/seko/dollibar/dolibarr-3.7.1/htdocs/webservices/server_invoice.php?wsdl) 请注意,您需要从$线阵列删除“payment_mode_id”字段,并将它移动到$发票阵列

像这样:

    $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 
         ); 

希望帮助

Regards