13 Replies Latest reply on Jul 23, 2009 7:08 AM by sean69

    Consuming webservice is consuming my patience! [updated]

    sean69

      I'm totally cross posting this....  sorry to be rude, just not getting any action in the advanced forum.

       

      Can anyone make this work?

      I'm trying to connect to/consume a webservice from a Magento commerce store [written in php] but am having problems with coldfusion not being able to "find" the methods I need to invoke.

       

      - I can create the object, log in, get a session but nothing [NOTHING!] else, none of the other methods are available - I just get a method not found error.

      - the user "register" with key "register" has permission to use them and I can [have] prove[n] that it works, I can for example call up  the store category tree VIAcatalogCategoryTree.

      - the dump of the mage_obj shows all the methods available.

      - The webservice is a Magento store [http://www.magentocommerce.com/]

      - The API documentation is here http://www.magentocommerce.com/support/magento_core_api

      - the webservice url is live, up and a test instance, so I am not afraid of it getting broken, please test to your heart's desire!

       

       

      <cfscript>

      mage_obj = CreateObject(webservice, http://mage.bigblock.ca/api/v2_soap?wsdl);
      mage_session = mage_obj.login('register','register');

      //retcat = mage_obj.catalogCategoryTree(mage_cats);

      </cfscript>

      <cfdump var="#mage_session#" />
      <cfdump var="#mage_obj#" />
      <!---cfdump var="#retcat#" /--->


       

      If anyone can take a look, give this a try - give me any clues as to why I can't access the webservice VIA CFMX, I would REALLY-REALLY appreciate it.

      I've been struggling with it for better than 2 days now. [more than 4 days now]

       

       

       

       

      - thanks in advance

      -sean

       

      Message was edited by: sean69

        • 2. Re: Consuming webservice is consuming my patience! [updated]
          -==cfSearching==- Level 4

          Can you provide an example of a method you are trying to access but cannot?

           

          I tried a few methods and both were found. Though catalogCategoryCurrentStore() returned "Requested store view not found" (obviously I did not know the valid storeView values ;-)

           

          attrList = mage_obj.catalogCategoryAttributeList(mage_session);
          store = mage_obj.catalogCategoryCurrentStore(mage_session, "test");

          • 3. Re: Consuming webservice is consuming my patience! [updated]
            sean69 Level 1

            You got data back? hmmm.... for all three examples you cited.  - some of these return data even if they fail [!explain that one!] so is hard to troubleshoot...

             

            this:

            //retcat = mage_obj.catalogCategoryTree(mage_cats);

             

            or the method

            catalogCategoryTree() // it's args are optional, so that should do it!

             

            should return the category tree on a cfdump - it should resemble the return data on this page http://mage.bigblock.ca/info.php

            [also if you dump the mage_obj - you should get a full method listing - though it looks like that is exactly what you did. - or here http://mage.bigblock.ca/index.cfm]

             

            thanks for looking in !

             

            -sean

            • 4. Re: Consuming webservice is consuming my patience! [updated]
              ilssac Level 5

              You did notice that in all the PHP examples that they pass the 'session' back into future operations, just like CFSearching did with his code.

              • 5. Re: Consuming webservice is consuming my patience! [updated]
                -==cfSearching==- Level 4

                [b]Update[/b] On second thought, the arguments for mage_obj.catalogCategoryTree(); do not seem to be optional.  If I pass in bogus values, it returns the the error:

                 

                100 - Requested store view not found.

                 

                 

                attrList = mage_obj.catalogCategoryAttributeList(mage_session);

                The results are pretty clear (no error)

                 

                <cfoutput>
                <cfloop from="1" to="#arrayLen(attrList)#" index="y">
                    <cfset x = attrList[y]>
                    attribute_id = #x.getAttribute_id()#|
                    code = #x.getCode()#|
                    type = #x.getType()#<br/>
                </cfloop>
                </cfoutput>
                <cfdump var="#attrList#" />

                 

                Can you give me something else to test?

                • 6. Re: Consuming webservice is consuming my patience! [updated]
                  sean69 Level 1

                  hmmm...  you're right [it would be nice if Magento documented this!]

                   

                  so, the line [in the mage_obj dump "catalogCategoryTree(java.lang.String, java.lang.String, java.lang.String)" is indicating that the method is expecting - nay - requiring 3 args?

                   

                  Or should I be looking to http://mage.bigblock.ca/api/v2_soap?wsdl to try and glean that information? cause they threw a bit of a torpedo at us, there are 2 service urls, the one above and http://mage.bigblock.ca/api/soap/?wsdl the former = not documented, the latter - is documented.... - http://www.magentocommerce.com/support/magento_core_api. now referring to that documentation: catalog APi -> catalogcategory.tree 2 args, both optional different datatypes than the soap2 api.... neither is the session_id [no I didn;t miss the php examples passing that]

                   

                  so now if I try to get a category list : catlist = mage_obj.catalogCategoryTree(mage_session, 'Default', 'Default'); [default being the name of the default store view]  I at least get a logical error "100 - Requested store view not found." [thank you!!]

                   

                  Ok - thank you, this is obviously a case of me "missing something":

                   

                  1. is everything I need to know about a method in that mage_obj dump ? i.e. number of args, data types etc?

                  2. if not where did you get that  info from [so quickly!]

                  3. something to test... hmmm... getting a category list would be good, though the problem is that we don't know what "store view" name the API is expecting, in the admin it is known as "default" or "Default Store View" - however these views are not sound.

                   

                  BTW - thanks so much, this is progress.

                   

                  -sean

                  • 7. Re: Consuming webservice is consuming my patience! [updated]
                    -==cfSearching==- Level 4

                    sean69 wrote:

                     

                    1. is everything I need to know about a method in that mage_obj dump ? i.e. number of args, data types etc?

                    2. if not where did you get that  info from [so quickly!]

                    3. something to test... hmmm... getting a category list would be good, though the problem is that we don't know what "store view" name the API is expecting, in the admin it is known as "default" or "Default Store View" - however these views are not sound.

                     


                    Hmm, they have to provide a list of valid codes somewhere.  I just got the information from the looking at the dump and the wsdl you are calling. I figured that has to be the most detailed and accurate (ie it is what determines whether the request is valid or not).

                    1 person found this helpful
                    • 8. Re: Consuming webservice is consuming my patience! [updated]
                      sean69 Level 1

                      Yes - I struggle with thier docs everyday, at first glance they look pretty good, but once you get into them..... 

                       

                      Hmm, they have to provide a list of valid codes somewhere.

                       

                      I have not been able to find one - the v1 soap wdsl is documented - but as we've seen not very useful to the "java friendly" v2 wsdl...  I have a post in their forum, but there is almost no developer help there and most people are looking for solutions and are kinda light on the "help" part of participating in a forum.

                       

                      But, thank you, you have proven that in fact this does work and all I need is some actual documentation.

                       

                      -thanks

                      -sean

                      • 9. Re: Consuming webservice is consuming my patience! [updated]
                        -==cfSearching==- Level 4

                        Yes documentation is often the last thing to be updated (unfortunately).  Well, if you find anything useful post back here ... for the next poor soul in your shoes.

                        • 10. Re: Consuming webservice is consuming my patience! [updated]
                          sean69 Level 1

                          OK - something odd has happened....check it out.

                           

                          <cfscript>
                          mage_obj = CreateObject("webservice", "http://mage.bigblock.ca/api/v2_soap?wsdl");
                          mage_session = mage_obj.login('register','register');
                          
                          retcat = mage_obj.catalogCategoryTree(mage_session,'1','default');
                          retn = retcat.getName();
                          retc = retcat.getChildren();
                          </cfscript>
                          
                          <cfdump var="#retcat#" />
                          <cfdump var="#retc#" />
                          <cfdump var="#retn#" />
                          

                          is now returning an object with methods - as opposesd to a category list, as it's supposed to, .... [http://mage.bigblock.ca/index.cfm]

                           

                          - more confused than ever

                          - had to guess at the "valid args" for catalogCatagoryTree

                          - still no docs anywhere

                          - I thought "ok" when retn returned the actual category name

                          - then retc returns the same object...

                           

                           

                           

                          I thought I was winning this battle...  argh!

                           

                          -sean

                          • 11. Re: Consuming webservice is consuming my patience! [updated]
                            -==cfSearching==- Level 4

                            sean69 wrote:

                             

                            is now returning an object with methods - as opposesd to a category list, as it's supposed to, .... [http://mage.bigblock.ca/index.cfm]

                             

                            - more confused than ever

                            - had to guess at the "valid args" for catalogCatagoryTree

                            - still no docs anywhere

                            - I thought "ok" when retn returned the actual category name

                            - then retc returns the same object...

                             

                             

                             

                            I thought I was winning this battle...  argh!

                             

                            -sean

                            It seems to be behaving correctly to me. Granted I know very little about the product.  If you look at the wsdl it says getChildren returns an array, which it does:

                             

                            <element name="children" type="typens:ArrayOfCatalogCategoryEntities"/>

                             

                            If you loop through the array of objects, you will see the first child is not the same object.

                             

                            <cfscript>
                                mage_obj = CreateObject("webservice", "http://mage.bigblock.ca/api/v2_soap?wsdl");
                                mage_session = mage_obj.login('register','register');
                                tree = mage_obj.catalogCategoryTree(mage_session,'1','default');
                                treeName = tree.getName();
                                treeChildren = tree.getChildren();
                            </cfscript>

                             

                            <cfoutput>
                            <b>tree:</b><br/>
                                getCategory_Id() = #tree.getCategory_Id()# |
                                getName() = #tree.getName()# |
                                getLevel() = #tree.getLevel()# |
                                getParent_Id() = #tree.getParent_Id()# |
                                getPosition() = #tree.getPosition()# <br/>

                             

                            <b>children:</b><br/>
                            <cfloop from="1" to="#arrayLen(treeChildren)#" index="i">
                                <cfset child = treeChildren[i] />
                                getCategory_Id() = #child.getCategory_Id()# |
                                getName() = #child.getName()# |
                                getLevel() = #child.getLevel()# |
                                getParent_Id() = #child.getParent_Id()# |
                                getPosition() = #child.getPosition()# <br/>
                            </cfloop>
                            </cfoutput>

                             

                            Message was edited by: -==cfSearching==-   Added missing code

                            1 person found this helpful
                            • 12. Re: Consuming webservice is consuming my patience! [updated]
                              -==cfSearching==- Level 4

                              Did you make any more progress on this one?

                              • 13. Re: Consuming webservice is consuming my patience! [updated]
                                sean69 Level 1

                                Actually, no, I have not had a chance to get back to it. Though chances look pretty slim that we will be going ahead with this method as there is a) no documentation for the v2_soap api & 2) there are no cart/store session methods available [I would have to write!]

                                 

                                I really would like to proceed and try to recover some of the time spent, but it looks like no.

                                 

                                the big reason for using the api was to get some store info [products] into a cart in the remote app, pass that back to magento - send the user to the mage site with a session and use the mage checkout/credit card processing. Mostly to keep the audit trail in one place. However it looks like it is going to be easier to use the paypal coldfusion api [which I have already tested successfully] to do this and just write some custom reporting tools.

                                 

                                Oh well, maybe will get back to it someday as looks like we will be using Magento quite heavily.

                                 

                                thanks for all your help.

                                 

                                PS> I did try some methods that needed arrays passed as the arg collection, tried cfarguments, passing cf arrays, and structures. never did get any to return more than an error before I had to abandon it.