Moodle
  1. Moodle
  2. MDL-28988

SOAP server should generate WSDL with fully detailed arrays

    Details

      Description

      History of the issue can be followed there: MDL-20804

      Summary: the SOAP server does not generate a detailled phpdoc for arrays. And so it does not generate generate a WSDL with fully detailled arrays. Arrays need to be fully detailled in the WSDL in order to be JAVA compatible (from my understanding of SOAP with JAVA).
      By fully detailled I mean the array content that could be objects, arrays or primitive type need to be described.

      At this moment we could try to generate an detailled phpdoc for array but I'm not sure if it's possible. If it's not possible then the solution would to parse the description and generate the WSDL without using the Zend reflection that look to the generated phpdoc.
      Also in this case we need to think if we prefer to have a new JAVA SOAP server and keep the current one or to change the current one.

        Gliffy Diagrams

        1. server.php.xml
          34 kB
          Luis de Vasconcelos

          Issue Links

            Activity

            Hide
            Federico added a comment -

            I'm working on this issue. Now i can generate a full detailed array for input parameter. Client like Axis 1.4 can generate the correct class structure and moodle act as expected.
            The return type isn't correct. Moodle return an HashMap for every ws, even if the structure declared in xxx_returns() is an object.
            At this moment, i can return the data type object[] that can be cast to HashMap client side. I can't to this for non array data, because the corrisponding wsdl type is struct, that is not recognized by axis.
            The best solution, IMHO, is modify the soap server to return direcly an object instead of an hashmap.
            Another way is create a wsdl telling the client that the returned type is an hashmap or an hashmap[].

            Show
            Federico added a comment - I'm working on this issue. Now i can generate a full detailed array for input parameter. Client like Axis 1.4 can generate the correct class structure and moodle act as expected. The return type isn't correct. Moodle return an HashMap for every ws, even if the structure declared in xxx_returns() is an object. At this moment, i can return the data type object[] that can be cast to HashMap client side. I can't to this for non array data, because the corrisponding wsdl type is struct, that is not recognized by axis. The best solution, IMHO, is modify the soap server to return direcly an object instead of an hashmap. Another way is create a wsdl telling the client that the returned type is an hashmap or an hashmap[].
            Hide
            Jérôme Mouneyrac added a comment - - edited

            Thanks for working on this issue Federico. When submitting a patch, use Github if possible, it's a lot easier for the peer-reviewer (often it's me concerning web service ) to have a look to the code in a github repository branch.
            Cheers,
            Jerome

            PS: in the case your SOAP server changes break existing SOAP clients, then the changes would not be accepted. However, in the case where we can not modify the SOAP server without breaking existing clients, then we still can create/extend another SOAP server.

            Show
            Jérôme Mouneyrac added a comment - - edited Thanks for working on this issue Federico. When submitting a patch, use Github if possible, it's a lot easier for the peer-reviewer (often it's me concerning web service ) to have a look to the code in a github repository branch. Cheers, Jerome PS: in the case your SOAP server changes break existing SOAP clients, then the changes would not be accepted. However, in the case where we can not modify the SOAP server without breaking existing clients, then we still can create/extend another SOAP server.
            Hide
            Federico added a comment -

            git://github.com/ghigio/moodle.git
            I've created the branch MDL-28988.

            Show
            Federico added a comment - git://github.com/ghigio/moodle.git I've created the branch MDL-28988 .
            Hide
            Jérôme Mouneyrac added a comment -

            Hi Frederico,
            in your last forum message (15th May) you said:

            My code generate a valid WSDL for the input type of all function. The returned type instead is not correct.

            The moodle soap server return an HashMap (kay, value) or an array of HashMap instead of objects. I could not generate a WSDL who describe this structure.

            I try to look at your branch but I can't see your commit(s). I try a compare but it was not helpful either. To make it easy for other to see your changes you should keep your master unchanged and up to date. In your branch you should make your changes and before pushing you should "git rebase master", then "git push -f origin MDL-28988".

            Otherwise in your forum message you mention you can not generate the part of the WSDL for the returned structure. It should be possible to ask the server to tweak the type (array => object) with a parameter when calling the server.

            Show
            Jérôme Mouneyrac added a comment - Hi Frederico, in your last forum message (15th May) you said: My code generate a valid WSDL for the input type of all function. The returned type instead is not correct. The moodle soap server return an HashMap (kay, value) or an array of HashMap instead of objects. I could not generate a WSDL who describe this structure. I try to look at your branch but I can't see your commit(s). I try a compare but it was not helpful either. To make it easy for other to see your changes you should keep your master unchanged and up to date. In your branch you should make your changes and before pushing you should "git rebase master", then "git push -f origin MDL-28988 ". Otherwise in your forum message you mention you can not generate the part of the WSDL for the returned structure. It should be possible to ask the server to tweak the type (array => object) with a parameter when calling the server.
            Hide
            Federico added a comment - - edited

            Sorry, my fault. I have not push the branch. I'm doing it asap. I have not make any change to the master.
            The problem is not the type array => object, but hashmap => object. The server return an array of hashmap instead an array of object.

            Edit: now i have update the repo with the new master and my branch.

            Show
            Federico added a comment - - edited Sorry, my fault. I have not push the branch. I'm doing it asap. I have not make any change to the master. The problem is not the type array => object, but hashmap => object. The server return an array of hashmap instead an array of object. Edit: now i have update the repo with the new master and my branch.
            Hide
            Jérôme Mouneyrac added a comment - - edited

            Hi Federico,
            thanks it's better to see the changes.
            In the amf server, Jamie cast the single structure into an object: https://github.com/ghigio/moodle/blob/master/webservice/amf/locallib.php#L134-155

            I suppose you could to do something similar things in SOAP.

            Show
            Jérôme Mouneyrac added a comment - - edited Hi Federico, thanks it's better to see the changes. In the amf server, Jamie cast the single structure into an object: https://github.com/ghigio/moodle/blob/master/webservice/amf/locallib.php#L134-155 I suppose you could to do something similar things in SOAP.
            Hide
            Federico added a comment -

            Hi,
            thanks Jerome for the tip. Today i have committed a new fix. Now the server return object or array of objets.

            The soap server make a valid wsdl. I've tried it with axis and all work.

            Plase, try it and give me a feedback.

            Show
            Federico added a comment - Hi, thanks Jerome for the tip. Today i have committed a new fix. Now the server return object or array of objets. The soap server make a valid wsdl. I've tried it with axis and all work. Plase, try it and give me a feedback.
            Hide
            Federico added a comment -

            Hi,
            today I have added a new branch on git://github.com/ghigio/moodle.git called MDL-28988-v2.

            In this brach I have added a new webservice called soapfda for preserve the current soap server.

            Show
            Federico added a comment - Hi, today I have added a new branch on git://github.com/ghigio/moodle.git called MDL-28988 -v2. In this brach I have added a new webservice called soapfda for preserve the current soap server.
            Hide
            Luis de Vasconcelos added a comment -

            Thanks Federico. Does your new code now generate a valid WSDL? According to your note on 23 Jul 2012 it does, but where is the code for that? Is it included in your MDL-28988-v2 branch?

            Thanks.

            Show
            Luis de Vasconcelos added a comment - Thanks Federico. Does your new code now generate a valid WSDL? According to your note on 23 Jul 2012 it does, but where is the code for that? Is it included in your MDL-28988 -v2 branch? Thanks.
            Hide
            Federico added a comment -

            Yes, it generate a valid wsdl. I have tried it with axis and soapui.

            to obtain the new wsdl simply call: http://your-moodle/webservice/soapfda/server.php?wsdl=1&wstoken=yourtoken

            Show
            Federico added a comment - Yes, it generate a valid wsdl. I have tried it with axis and soapui. to obtain the new wsdl simply call: http://your-moodle/webservice/soapfda/server.php?wsdl=1&wstoken=yourtoken
            Hide
            Luis de Vasconcelos added a comment -

            Thanks. I installed the MDL-28988-v2 branch on localhost and ran the /webservice/soapfda/server.php call. I've attached the WSDL that was created.

            I'll pass it on to my Web Services gurru and get him to check it. I'm mostly interested in consuming Moodle web services via MS BizTalk.

            Show
            Luis de Vasconcelos added a comment - Thanks. I installed the MDL-28988 -v2 branch on localhost and ran the /webservice/soapfda/server.php call. I've attached the WSDL that was created. I'll pass it on to my Web Services gurru and get him to check it. I'm mostly interested in consuming Moodle web services via MS BizTalk.
            Hide
            Federico added a comment -
            Show
            Federico added a comment - Hi, i have published this plugin at https://moodle.org/plugins/view.php?plugin=webservice_soapfda
            Hide
            Johann Kneringer added a comment -

            Hi Frederico,

            thanks a lot! I made it work with axis2 and wsdl2java to generate the ServiceStub to use with in a java client.

            The thing is to generate the java-code by using the databinding option for xmlbeans in axis2 (-d xmlbeans).

            At the moment I am able to create categories and courses. I will test other methods too.

            Show
            Johann Kneringer added a comment - Hi Frederico, thanks a lot! I made it work with axis2 and wsdl2java to generate the ServiceStub to use with in a java client. The thing is to generate the java-code by using the databinding option for xmlbeans in axis2 (-d xmlbeans). At the moment I am able to create categories and courses. I will test other methods too.
            Hide
            Jonathan Moore added a comment - - edited

            Anyone have an idea of the scope to complete this so that WSDL works with .Net? @Federico should your plugin work with .Net? https://moodle.org/plugins/view.php?plugin=webservice_soapfda

            Show
            Jonathan Moore added a comment - - edited Anyone have an idea of the scope to complete this so that WSDL works with .Net? @Federico should your plugin work with .Net? https://moodle.org/plugins/view.php?plugin=webservice_soapfda
            Hide
            Jonathan Moore added a comment -

            @Jérôme Mouneyrac are there any blockers to adding @Federico plugin to core? This issue has been around for 2 years and I think it would really be a big step forward for core WS to have easy support for non PHP dev environments. I did a lot of early days WS work while at Remote Learner using the OK Tech WS and the number one consumer of the functionality was .Net developers. If there is some hope of this getting to core, I have an active project that would allow me to put some time into the process.

            Show
            Jonathan Moore added a comment - @Jérôme Mouneyrac are there any blockers to adding @Federico plugin to core? This issue has been around for 2 years and I think it would really be a big step forward for core WS to have easy support for non PHP dev environments. I did a lot of early days WS work while at Remote Learner using the OK Tech WS and the number one consumer of the functionality was .Net developers. If there is some hope of this getting to core, I have an active project that would allow me to put some time into the process.
            Hide
            Federico added a comment -

            I'm sorry, but actually there is a bug in my plugin.
            It generate a fully documented wsdl, but when it process a request, the plugin crashes because it can't convert back the array of object inside the xml. I think it work only for non array object.
            I'm really sorry for this issue. I tried to correct this, but i can't figure out how.

            Show
            Federico added a comment - I'm sorry, but actually there is a bug in my plugin. It generate a fully documented wsdl, but when it process a request, the plugin crashes because it can't convert back the array of object inside the xml. I think it work only for non array object. I'm really sorry for this issue. I tried to correct this, but i can't figure out how.

              People

              • Votes:
                20 Vote for this issue
                Watchers:
                17 Start watching this issue

                Dates

                • Created:
                  Updated: