SOAP API changes with 8.7.11 ?

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
tizoo
Posts: 3
Joined: Mon Aug 28, 2017 4:00 pm

SOAP API changes with 8.7.11 ?

Postby tizoo » Mon Aug 28, 2017 4:43 pm

Hi,

We use the SOAP API from PHP to manage Zimbra servers from cPanel.

Everything worked well with zimbra 8.7.7, but since we updated to 8.7.11, some commands don't work anymore and we don't succeed on finding why...

For example, all the following commands still works :

CreateDomainRequest
DeleteDomainRequest
GetDomainInfoRequest
GetAllDomainsRequest
GetAllAccountsRequest
SetPasswordRequest

But those don't work anymore :

* GetAccountRequest returns the following error :

[previous:Exception:private] =>
[faultstring] => invalid request: missing
[faultcode] => soap:Sender
[detail] => stdClass Object
(
[Error] => stdClass Object
(
[Code] => service.INVALID_REQUEST
[Trace] => qtp1068934215-19877:1503936723309:b3e07d429f357082
)
)

* GetMailboxRequest retuns :

[previous:Exception:private] =>
[faultstring] => system failure: java.lang.NullPointerException
[faultcode] => soap:Receiver
[detail] => stdClass Object
(
[Error] => stdClass Object
(
[Code] => service.FAILURE
[Trace] => qtp1068934215-19889:1503936877152:b3e07d429f357082
)
)

* ModifyAccountRequest don't make an error, but just don't do the changes.


I don't find anything in the ChangeLog about those requests and the returned errors are, not really informative.

Did someone has some tips to help us track and fix the problem ?

Is there a log file do we have to look in to have more information about the errors ?

Thanks in advance for any information.

Philippe


tizoo
Posts: 3
Joined: Mon Aug 28, 2017 4:00 pm

Re: SOAP API changes with 8.7.11 ?

Postby tizoo » Tue Aug 29, 2017 2:42 pm

Hello,

Some additionnal informations, that seems to show a problem in the SOAP API 8.7.11.

The following SOAP request sent to a Zimbra OS 8.7.7 server perfectly works (got with PHP SoapClient::__getLastRequest):

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:zimbraAdmin" xmlns:ns2="urn:zimbra">
   <env:Header>
      <ns2:context>
         <param_name>authToken</param_name>
         <param_data>0_b3...7363b</param_data>
      </ns2:context>
   </env:Header>
   <env:Body>
      <ns1:GetAccountRequest>
         <account by="id">11111111-1111-1111-1111-111111111111</account>
      </ns1:GetAccountRequest>
   </env:Body>
</env:Envelope>


But the same request sent to a Zimbra NE 8.7.11 server return a really strange exception about "<account>" not present :

Code: Select all

SoapFault Object
(
  [message:protected] => invalid request: missing <account>
  [string:Exception:private] =>
  [code:protected] => 0
  [file:protected] => /var/www/plugin/test/tza.php
  [line:protected] => 413
  [trace:Exception:private] => Array
  (
    [0] => Array
    (
      [file] => /var/www/plugin/test/tza.php
      [line] => 413
      [function] => __soapCall
      [class] => SoapClient
      [type] => ->
      [args] => Array
      (
        [0] => GetAccountRequest
        [1] => Array
        (
          [0] => SoapVar Object
          (
            [enc_type] => 147
            [enc_value] => <account by="id">11111111-1111-1111-1111-111111111111</account>
          )
        )
        [2] =>
        [3] => SoapHeader Object
        (
          [namespace] => urn:zimbra
          [name] => context
          [data] => SoapParam Object
          (
            [param_name] => authToken
            [param_data] => 0_e50fa3835343b
          )
          [mustUnderstand] =>
        )
      )
    )
    [1] => Array
    (
      [file] => /var/www/plugin/test/main.php
      [line] => 23
      [function] => getAccountNameAndID
      [class] => TZapi
      [type] => ->
      [args] => Array
      (
        [0] => 11111111-1111-1111-1111-111111111111
      )
    )
  )
  [previous:Exception:private] =>
  [faultstring] => invalid request: missing <account>
  [faultcode] => soap:Sender
  [detail] => stdClass Object
  (
    [Error] => stdClass Object
    (
      [Code] => service.INVALID_REQUEST
      [Trace] => qtp1068934215-28084:1504015257189:b3e07d429f357082
    )
  )
)


It seems that the server SOAP doesn't parse correctly the encoded parameter '<account by="id">'.

Is it something that we make false ? I don't see any changes between 8.7.7 and 8.7.11 to use GetAccount request.

Thanks for any tips that could help us fix this problem.

Best,
Philippe
User avatar
msquadrat
Advanced member
Advanced member
Posts: 162
Joined: Mon Oct 14, 2013 10:09 am

Re: SOAP API changes with 8.7.11 ?

Postby msquadrat » Tue Aug 29, 2017 3:13 pm

Hi Philippe,

I might be wrong but from a quick glance I'd say that your request shouldn't have worked before already. There are two oddities I see.

First:

Code: Select all

      <ns2:context>
         <param_name>authToken</param_name>
         <param_data>0_b3...7363b</param_data>
      </ns2:context>

This should actually be:

Code: Select all

      <ns2:context>
         <ns2:authToken>0_b3...7363b</ns2:authToken>
      </ns2:context>



And later on:

Code: Select all

      <ns1:GetAccountRequest>
         <account by="id">11111111-1111-1111-1111-111111111111</account>
      </ns1:GetAccountRequest>

This should actually be:

Code: Select all

      <ns1:GetAccountRequest>
         <ns1:account by="id">11111111-1111-1111-1111-111111111111</ns1:account>
      </ns1:GetAccountRequest>

Or maybe:

Code: Select all

      <GetAccountRequest xmlns="urn:zimbraAdmin">
         <account by="id">11111111-1111-1111-1111-111111111111</account>
      </GetAccountRequest>


IIRC was there an update of some XML Java library (Xerxes?) in 8.7.x maybe that one is more strict now.
User avatar
Gren Elliot
Zimbra Employee
Zimbra Employee
Posts: 183
Joined: Tue Jun 10, 2014 4:45 am

Re: SOAP API changes with 8.7.11 ?

Postby Gren Elliot » Wed Aug 30, 2017 3:04 pm

I'm not 100% certain of why things have changed but I can make a pretty good guess. We're trying to migrate the SOAP request handlers to use JAXB objects - which are the Java classes that we generate the WSDL definitions from and create the SOAP documentation from. This helps us to avoid the handlers accidentally get out of sync with the documentation - which is quite easy to do using that hand crafted legacy XML/JSON library we historically used. One downside is that JAXB is strict about the corresponding XML or JSON in ways the more relaxed XML library is not.
tizoo
Posts: 3
Joined: Mon Aug 28, 2017 4:00 pm

Re: SOAP API changes with 8.7.11 ?

Postby tizoo » Thu Aug 31, 2017 9:23 am

Hi msquadrat, Elliot,

Thanks a lot for your informations that helped us fix the problem in our code.

It was effectively due to the missing namespace specification in the parameters, thanks msquadrat.

And as said by Elliot, this strictness has been brought by the change from XML library to JAXB, thus before 8.7.11, everything worked like a charm :-)

Thanks again and have a nice week-end,

Philippe
johnroberts
Posts: 21
Joined: Sat Sep 13, 2014 2:43 am

Re: SOAP API changes with 8.7.11 ?

Postby johnroberts » Sun Sep 24, 2017 11:51 am

Also thanks msquadrat!

We use the ZimbraSoapPhp package which started throwing exceptions after the update to 8.7.11. The above information helped us to fix the package and get it back up and working.

For information the changes affected every occurrence of SoapVar in each of the php scripts. To help any others which might have problems with the package the changes are shown below (first line original, second line correction):

Code: Select all

new SoapVar('<ns2:context><authToken>' . $authToken . '</authToken></ns2:context>', XSD_ANYXML)
new SoapVar('<ns2:context><ns2:authToken>' . $authToken . '</ns2:authToken></ns2:context>', XSD_ANYXML)


Code: Select all

new SoapVar('<domain by="' . $realType . '">' . $idOrNameDomain . '</domain>', XSD_ANYXML),
new SoapVar('<ns1:domain by="' . $realType . '">' . $idOrNameDomain . '</ns1:domain>', XSD_ANYXML),


Code: Select all

new SoapVar('<account by="name">' . $name . '</account>', XSD_ANYXML),
new SoapVar('<ns1:account by="name">' . $name . '</ns1:account>', XSD_ANYXML),


Code: Select all

$params[] = new SoapVar('<a n="' . $key . '">' . $value . '</a>', XSD_ANYXML);
$params[] = new SoapVar('<ns1:a n="' . $key . '">' . $value . '</ns1:a>', XSD_ANYXML);


Code: Select all

$params[] = new SoapVar('<pref name="' . $key . '">' . $value . '</pref>', XSD_ANYXML);
$params[] = new SoapVar('<ns1:pref name="' . $key . '">' . $value . '</ns1:pref>', XSD_ANYXML);


Code: Select all

new SoapVar('<cos by="name">' . $name . '</cos>', XSD_ANYXML),
new SoapVar('<ns1:cos by="name">' . $name . '</ns1:cos>', XSD_ANYXML),


Code: Select all

new SoapVar('<server by="name">' . $name . '</server>', XSD_ANYXML),
new SoapVar('<ns1:server by="name">' . $name . '</ns1:server>', XSD_ANYXML),
User avatar
msquadrat
Advanced member
Advanced member
Posts: 162
Joined: Mon Oct 14, 2013 10:09 am

Re: SOAP API changes with 8.7.11 ?

Postby msquadrat » Sun Sep 24, 2017 12:00 pm

johnroberts wrote:We use the ZimbraSoapPhp package which started throwing exceptions after the update to 8.7.11. The above information helped us to fix the package and get it back up and working.


Just out of interest: Which of all the available Zimbra PHP libraries is that?
johnroberts
Posts: 21
Joined: Sat Sep 13, 2014 2:43 am

Re: SOAP API changes with 8.7.11 ?

Postby johnroberts » Sun Sep 24, 2017 1:45 pm

msquadrat wrote:Just out of interest: Which of all the available Zimbra PHP libraries is that?

Actually I just tried to find the repo but can't locate it...

I also just emailed the developers the updates.

The script headers include:

/**
* Zm_Auth
*
* @author Yannick Lorenz <ylorenz at 1g6.biz>
* @author Fabrizio La Rosa <fabrizio.larosa at unime.it>
* @version 2.0
* @copyright Copyright (c) 2009, Yannick Lorenz
* @copyright Copyright (c) 2012, Fabrizio La Rosa
* @package ZimbraSoapPhp
*/
User avatar
msquadrat
Advanced member
Advanced member
Posts: 162
Joined: Mon Oct 14, 2013 10:09 am

Re: SOAP API changes with 8.7.11 ?

Postby msquadrat » Sun Sep 24, 2017 5:52 pm

johnroberts wrote:
msquadrat wrote:Just out of interest: Which of all the available Zimbra PHP libraries is that?

Actually I just tried to find the repo but can't locate it...

I also just emailed the developers the updates.


Looks like this was hosted on Google Code and there is an repo by the original author to GitHub which has at least one commit. I found at least one other fork which has some other changes. All in all it looks like a pretty dead project…
11432fab
Posts: 39
Joined: Fri Sep 12, 2014 11:52 pm

Re: SOAP API changes with 8.7.11 ?

Postby 11432fab » Mon Sep 25, 2017 2:04 pm

Hi all,
of the three SOAP API packages mentioned by msquadrat this is the one I'm still maintaining on Github:
https://github.com/lorenzyannick/zimbra ... its/master
I'll try to implement the new changes to make it compatible with the latest ZCS 8.7 releases, but we are still on 8.6 so I also have to test it here to be sure we don't break anything.

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 6 guests