Développement web indépendant à Montpellier

Publié le dimanche 22 janvier 2012 20:30:08

CodeIgniter v2 et Webservice avec ZendFramework

Dans un article plus ancien, j'avais expliqué comment créer des webservices avec CodeIgniter v1.7 en utilisant le Framework Zend pour générer le WSDL. CodeIgniter v2 est sorti entre temps, si le principe n'a pas réellement changé, voici tout de même comment créer un Webservice avec CodeIgniter v2 et ZF.

Import des fichiers Zend

Tout d'abord téléchargez les fichiers du framework Zend (les composants minimaux). Si vous n'êtes pas à l'aise avec la configuration de PHP et les include_path, vous pouvez placer le dossier Zend à la racine de votre application CodeIgniter :

Projet CodeIgniter Netbeans

De la même manière que pour codeigniter v1.7, créons maintenant la classe webservice.

Création du webservice

Nous créons le webservice dans le répertoire /application/soap ( /application/soap/soapservertest.php ).

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
class soapservertest
{
    var $ci;
    /**
     * Méthode très intéressante
     * @return string
     */
    function HelloWorld()
    {
        return "Hello World";
    }
    /**
     * Dis bonjour à quelqu'un
     * @param string $someone
     * @return string
     */
    function SayHelloToSomeOne($someone)
    {
        return "Hello $someone";
    }
    /**
     * Renvoi un tableau
     * @return array
     */
    function getWebsites()
    {
        return array('http://www.ligams.com','http://ligams.net');
    }
    /**
     * Appelle la base de donnée du site
     * @return string
     */
    function callSomethingInDataBase()
    {
        $this->ci =& get_instance();
        $this->ci->load->model('XXXXXX');
        $users = $this->ci->XXXXXX->selectAll();
        return json_encode($users);
    }
}
?>

Je ne reviens pas la dessus, il faut commenter cette classe, c'est grâce aux commentaires que sera généré le fichier WSDL, descripteur du webservice. Vous pouvez en savoir plus sur ce fichier en vous reportant à l'article Création de webservices en PHP.

Création du controller Webservice

Pas de différence avec CI v 1.7 :

<?php

require('Zend/Soap/Server.php');
require('Zend/Soap/AutoDiscover.php'); 
require('Zend/Soap/Server/Exception.php');
/**
 * Description of webservice
 * @author Stéphane
 */
class webservice extends MY_Controller {
    function serve($class,$wsdl = null)  
    {  
        /* 
         * sous-entend que vous placez vos classes webservice class dans le répertoire soap de votre app 
         * et qu'il est nommé NOMDEVOTRE WEBSERVICE.php 
         */  
        $path = APPPATH.'soap/'.$class.'.php';  
        if(file_exists($path))  
        {  
            require_once($path);  
            if($wsdl=='wsdl')  
            {  
                ini_set("soap.wsdl_cache_enabled",0);  
                $wsdl = new Zend_Soap_AutoDiscover();  
        $wsdl->setUri(base_url().get_class($this).'/serve/'.$class);  
                $wsdl->setClass($class);  
                $wsdl->handle();  
            }  
            else  
            {  
                $szWSDLUrl = base_url().get_class($this).'/serve/'.$class.'/wsdl';  
                $options = array('soap_version' => 2);  
                $server = new Zend_Soap_Server($szWSDLUrl,$options);  
                $server->setClass($class);  
                $server->handle();  
            }  
        }  
        else  
        {  
            show_404();  
        }  
    }
}

?>

Et voilà votre webservice crée avec CodeIgniter V2 !

Notez cet article !

  • Actuellement 5 sur 5 étoiles
  • 1
  • 2
  • 3
  • 4
  • 5

Note : 5/5 (4 notes attribuées)

Merci d'avoir participé !

Vous avez déjà noté cette page, vous ne pouvez la noter qu'une fois !

Votre note a été changée, merci de votre participation !

Bonne résolution ! j'arrête d'alourdir mes pages avec des boutons de partage, mais vous pouvez continuer de partager :-)

Commentaires

  1. Happy New wishes and messages for Sister in law are here. For the people searching for the New Year 2019 wishes for sister in law, we have shared this post where they can get the complete collection of New Year quotes, sms and wishes for sister in law.
    https:/...er-in-law/

  2. Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.
    http://...-for-2018/

  3. I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.
    http://...gazine.com

  4. I am happy to find this post very useful for me. as it contains lot of information. I always prefer to read the quality content and this thing I found in you post.

  5. This is an actor's picture if ever there is one and it in essence repeated its Golden Globe triumph of a couple of Sundays past with
    champions Frances McDormand

  6. Is it digital marketing that you have been searching for? We have promote in every type of socail media included and all the way to digital marketing services company: https:/...marketing/ And we are sure that you are looking for the very ones we have attached in our portfolio, you can head over to the website @ Brand-Platform.com for what you want. https:/...lications/

  7. Thank you for taking the time to publish this information very useful!
    http://...pecial.com

  8. http://ww... | http://www.poker18dewa.com |

    I needed to create you the little bit of observation in order to thank you as before for these magnificent principles you have discussed above. This has been certainly pretty open-handed with people like you to allow freely precisely what many of us would’ve offered for sale as an ebook in order to make some profit on their own, certainly seeing that you might well have tried it if you wanted. Those principles likewise acted to be a great way to fully grasp most people have a similar fervor like my very own to know somewhat more in terms of this problem. I am sure there are a lot more enjoyable times up front for individuals who read carefully your blog.

  9. lesa.prom... | information tchnology assignment help |

    Thank you for the remarkable blog. The information technology assignment help expert is really pleased to find this blog.

  10. Thank for the post. Our chemistry assignment help expert are quite impressed.

  11. yogeshkum... | Brown black leather travel diary journal UK |

    The travel diary journal features a very high quality leather cover sourced from Yorkshire UK; and hand-finish in London UK. The 2mm thick cover for our travel diary journals are made from the finest quality, full grain leather. The really special thing about the travel diary journal is the range of accessories and refills available. Also included is a 100% cotton drawstring carry bag, and a kraft file insert with pockets for paperwork, cards and cash. Each travel diary journal is presented in a sturdy kraft card gift box.

  12. lesa.prom... | statistics assignment help |

    Thank you for the wonderful blog. Our statistics assignment help experts are grateful to see your blog.

  13. yogeshkum... | A4/A3/A2/A1 Peak Laminators |

    I have worked within the binding and laminating industry for the past 28 years gaining much knowledge along the way which means that there is not much that I can't help you with and we know how to deliver an outstanding service to all businesses regardless of large corporations, small independent businesses or a re-seller.

  14. Thank you for excellent blog! Our writer is really happy to get zendframework blog. As thesis help online expert, i am really impressed.

  15. Thank you for the excellent blog. The blog is really helpful. Our coursework assignment help experts are fascinated by this blog.

  16. We have personally chosen a range of hotels and venues across the UK that offer an interesting and luxurious environment for your events.

  17. yogeshkum... | chiropractor in cambridge |

    To find my website when anybody searches for chiropractor or chiropractors in cambridge.

  18. yogeshkum... | Renew expired registration |

    I am content to find your own personal known manner of submitting ones write-up. At the moment an individual allow it to become possible for us to be aware of and also apply the style. Thanks towards the write-up.

  19. Are you an iOS device user? If yes. Then you might have known well about Apple iCloud and how to login iCloud on your iOS device

  20. I all the time used to study article in news papers but now as I am a user of net thus from now I am using net for posts, thanks to web. Take a look at my homepage.

  21. Packers i... | Packers and Movers in Lucknow |

    Packers and Movers in Lucknow

  22. yogeshkum... | bridging finance solutions |

    Bridging loans are specialty loan products that offer short-term financing for real estate transactions of many different types. While many purchasers are not aware of the many benefits of bridging loans, they can offer a flexible and affordable finance option that helps real estate buyers avoid delays.

  23. Auto Glas... | Auto Glass Replacement |

    As soon as I noticed this website I went on reddit to share some of the love with them.

  24. reynairio... | Pay someone to do my essay |

    I guess the top companies would be the ones that employ contributors to the framework. They build it and are familiar with the inside scoop of what's coming. If you need to do a quality projects without skipping any steps that I would recommend ZendFramework.

  25. I have a hard time describing my thoughts on content, but I really felt I should here. Your article is really great. I like the way you wrote this information.

  26. packers a... | packers and movers agra |

    packers and movers agra

  27. packers a... | packers and movers kanpur |

    packers and movers kanpur

  28. packers a... | packers and movers allahabad |

    packers and movers allahabad

  29. packers a... | packers and movers varanasi |

    packers and movers varanasi

  30. packers a... | packers and movers jalandhar |

    packers and movers jalandhar

  31. packers a... | packers and movers mohali |

    packers and movers mohali

  32. packers a... | packers and movers panchkula |

    packers and movers panchkula

  33. packers a... | packers and movers ludhiana |

    packers and movers ludhiana

  34. packers a... | packers and movers amritsar |

    packers and movers amritsar

  35. packers a... | packers and movers cochin |

    packers and movers cochin

  36. packers a... | packers and movers coimbatore |

    packers and movers coimbatore

  37. packers a... | packers and movers trichy |

    packers and movers trichy

  38. packers a... | packers and movers madurai |

    packers and movers madurai

  39. packers a... | packers and movers visakhapatnam |

    packers and movers visakhapatnam

  40. packers a... | packers and movers pondicherry |

    packers and movers pondicherry

  41. packers a... | packers and movers vijayawada |

    packers and movers vijayawada

  42. packers a... | packers and movers vadodara |

    packers and movers vadodara

  43. packers a... | packers and movers rajkot |

    packers and movers rajkot

  44. packers a... | packers and movers surat |

    packers and movers surat

  45. packers a... | packers and movers ahmedabad |

    packers and movers ahmedabad

  46. Packers A... | Packers And Movers patna |

    Packers And Movers patna

  47. Packers A... | Packers And Movers raipur |

    Packers And Movers raipur

  48. Packers A... | Packers And Movers bhubaneswar |

    Packers And Movers bhubaneswar

  49. Packers A... | Packers And Movers Hyderabad |

    Packers And Movers Hyderabad

  50. Packers A... | Packers And Movers faridabad |

    Packers And Movers faridabad

  51. Packers A... | Packers And Movers Chandigarh |

    Packers And Movers Chandigarh

  52. Packers A... | Packers And Movers gurgaon |

    Packers And Movers gurgaon

  53. Packers A... | Packers And Movers Thane |

    Packers And Movers Thane

  54. Packers A... | Packers And Movers Indore |

    Packers And Movers Indore

  55. Packers A... | Packers And Movers chennai |

    Packers And Movers chennai

  56. Packers A... | Packers And Movers Bangalore |

    Packers And Movers Bangalore

  57. Packers A... | Packers And Movers Noida |

    Packers And Movers Noida

  58. Packers A... | Packers And Movers Kolkata |

    Packers And Movers Kolkata

  59. Packers A... | Packers And Movers delhi |

    Packers And Movers delhi

  60. Packers A... | Packers And Movers Mumbai |

    Packers And Movers Mumbai

  61. Packers A... | Packers And Movers Pune |

    Packers And Movers Pune

  62. Packers A... | Packers And Movers navi mumbai |

    Packers And Movers navi mumbai

  63. Packers A... | Packers And Movers Lucknow |

    Packers And Movers Lucknow

  64. AppValley Apk android is the best alternative for Google play store on android phones or devices. AppValley App is the right junction for getting all the free apps, games and their mods easily.

  65. User Guide for Installation of Webroot.com/safe Antivirus
    When you buy any antivirus product from this American brand, you can install the same on your device with ease. It is extremely convenient to install any of the security packages from Webroot with a few simple steps that you need to follow.

    1. To start with, you will have to download the antivirus software available at webroot.com/safe. This can be done with a powerful internet connection without a CD or DVD. You can also do this with the help of a retail card.

    2. Next step is accessing the unique 20 character alpha-numeric code (xxxx-xxxx-xxxx-xxxx) which is your product key. If you buy retail card, you will find this unique code on the backside of the card that you need to enter after you created your account and login.

    3. You can now Install Webroot with this Product Key by entering this unique product key. The installation process in now complete and you can click on the ‘Submit’ button.

    The Webroot.com/Setup Product Key makes it easy and convenient for all users to install antivirus without much help. However, if you run into any problem during the installation process, then here are a few tips for help.

  66. Install your webroot with these steps given below


    In the first step , i will give you the link , from there you can easily download your webroot . Please read all the steps in order to successfully install your antivirus .

    First of all ,click on the link www.webroot.com/safe

    On this page the download file is already there and it will be downloaded automatically if you have a google chrome browser . If you are using internet explorer (blue E) then a it will show you a option to save in the bottom. You need to click on save.

    Now it will show you another option to run you just need to click on run.If you do not find the download file , then you just need to press ctrl+j at the same time in order to open your download.

    If you successfully run the download file then it will show you a box , where you can put your keycode.( Keycode is a 20 digit alphanumeric set which is on the back of your card)

    Press agree and install

    Also your computer will prompt and you need to click on “yes”.

  67. Webroot Antivirus Installation Guide
    Antivirus and cyber security products from this brand are easy to use and install and can be done in a simple manner by following a few steps. The security package offered by this brand is incredibly easy to setup and install. You can easily install and upgrade any of the Webroot SecureAnywhere Antivirus products that help you handle cyber security in the best possible manner.

    Here is how you can do it in three simple steps:

    1. Start with setup and install at webroot.com/safe by downloading the software that you can do without a CD or DVD. All you need is a good internet connection for the purpose.

    2. You will find a 20 character alpha-numeric code (xxxx-xxxx-xxxx-xxxx) which is your product key. If you buy retail card, you will find this unique code on the backside of the card that you need to enter.

    3. Install Webroot with this Product Key by entering this unique product key to complete the installation process and clicking on the ‘Submit’ button.

    With the Webroot.com/Setup Product Key, you can complete the installation process all by yourself. Here are a few troubleshooting tips for a smooth Webroot installation.

    If the automatic download fails, you can call the helpline for assistance. Slow internet connections can lead to problems in downloading.

    If you already have an anti-virus installed on your device, you will have to uninstall that first and remove it completely from your system.

    Ensure that the latest updates are installed on your operating system so that it is compatible with the Webroot antivirus.

  68. Installation/Un-Installation of Webroot antivirus
    Re-installation of Webroot antivirus
    Upgradation of Webroot antivirus
    Activation of Webroot Antivirus product
    Repair of Webroot antivirus
    All kinds of software installations and programme updates
    Maintenance checks for all computers
    Compatibility checks with various software and programmes
    Reinstallation or update of your operating system
    Verification of protection and security
    Computer scans for the threats to analyse the virus infections
    Configure Webroot antivirus settings as per system requirements
    Security settings for complete protection

  69. welcome to avg.com/retail website With the development of the digital world, online protection is crucial. It is extremely important to protect your PCs, Mac, computers as well as mobile devices and tablets with avg.com/retail. This can be done with the help of effective internet security and anti-virus products from avg.com/retail that safeguards all devices used on digital platforms.

  70. Visit www.norton.com/setup for setup, download, reinstall, enter and activate your norton product key to setup your account.Step-by-Step guide for Norton setup key, Download &amp; installation from norton.com/setup website.

  71. Thank you for sharing the information! The idea of changing battery sounds better than waiting for the battery to recharging.

  72. Interesting and you have very nice way of expressing the article.The author clearly describe all the parts of the article with good language and information.Looking forward to another article.

  73. Your site has a lot of useful information for myself. I visit regularly. Hope to have more quality items

  74. https://v... | https://vegasweddingsplanner.com/ |

    This is an awesome rousing article.I am practically satisfied with your great work.You put truly exceptionally supportive data. Keep it up. Continue blogging. Hoping to perusing your next post.

  75. I am happy to find this post Very useful for me, as it contains lot of information. I Always prefer to read The Quality and glad I found this thing in you post. Thanks

  76. Generate Unlimited Resources with Our Newly Released Online Resources Generator Tool its 100% Working and also Free Tool, This is one of the best method.You should try this!. Enjoy it!

    https:/...-xtreme-4/

  77. MS Paint... | MS Paint Customer Service |

    Call MS Paint Customer support if you want to solve your MS Paint related queries. we have the best team of techies who can solve all your issues.

  78. Buy Harva... | Buy Harvard Business Case Studies Solutions |

    Great Information,it has lot for stuff which is informative.I will share the post with my friends.

  79. Science Channel’s are giving a complete knowledge to its viewers about every thing students write done dissertation on this subjects and show its importance.

  80. I personally like your post, you have shared good article. It will help me in great deal.

  81. This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works.

  82. NBA Live... | NBA Live Mobile Coins Cheapest  |

    Wonderful information, thanks a lot for sharing kind of information. Your website gives the best and the most interesting information. Thanks a ton once again, http://...edeal.com/

  83. MapQuest Driving Directions is restyled as Mapquest which is a well known free online web mapping service controlled by Verizon.

  84. J'ai trouvé que c'était un article attrayant et attrayant, donc je pense qu'il est particulièrement utile et compétent. Je tiens à vous remercier pour vos efforts dans la rédaction de cet article
    gogoanime https:/...-anime.io/

  85. A getting a handle on splendidly formed blog. Truly a present for its social affair of individuals.

  86. We are a London based company. Our services include, surveillance, car tracking, background reports and investigations.

  87. Appzy9 | Love what youre doing |

    <p>Love what youre doing here folks, keep it up!<br>
    Download Free apk online
    <a href="https:/...t;Download ShowBox apk</a><br>
    <a href="https:/...t;Download MovieBox apk</a><br>
    <a href="https:/...t;Download TubeMate apk</a><br>
    <a href="https:/...t;Download Blackmart apk</a><br>
    <a href="https:/...t;Download adBlack apk</a><br>
    <a href="https:/...t;Download Whatsup+ apk</a></p>

  88. This script is really useful work me. I will use this controller script on my site as I have to maintain some remote parameters.

  89. Tonsil stones are fundamentally caused in tonsils. It’s only a piece of our skin which gets influenced by the infections

  90. jaylenmik... | Restauranter Drammen |

    This blog is so nice to me. I will keep on coming here again and again. Visit my link as well..
    https:/...r/drammen/

  91. https://c... | https://case-study-analysis.com |

    I personally like your post, you have shared good article. It will help me in great deal.

  92. https://c... | https://capstoneprojects.help/ |

    Great Information,it has lot for stuff which is informative. I will share the post with my friends.

  93. Great! It sounds good. Thanks for sharing..

  94. This is such an incredible asset, to the point that you are giving and you give it away for nothing. I cherish seeing blog that comprehend the quality. Great post ultimate blog..!!

  95. Website | Modded Apks and Games |

    Check Our Site To Download Modded Apks and Hacked Games

  96. home reme... | home remedies for sore throat and cough |

    I think this is a really good article. You make this information interesting and engaging. home remedies for sore throat and cough You give readers a lot to think about and I appreciate that kind of writing.

  97. i read a considerable measure of stuff and i found that the method for composing to clearifing that precisely need to say was great so i am awed and ilike to come back again in future..

  98. ibps cler... | ibps clerk answer key 2017 |

    ibps clerk answer key 2017 Here is the www.ibps.in Clerical Exam Cutoff Marks 2017 update. IBPS Clerk Prelims Exam Solution sheet 2017

  99. I have a hard time describing my thoughts on content, but I really felt I should here. Your article is really great. I like the way you wrote this information.

  100. Cogniflex is another mind upgrade supplement which cases to be the most developed and compelling


  101. Get Fun facts and mathematical calculations of numbers. Check whether a number is a prime number or composite number. Check if a number is even or odd number math solvers

  102. When I saw your article, especially this post you satisfied me amazingly.

  103. happywhee... | happy wheels |

    Great post. I found your website perfect for my needs. Very useful info specifically the last part. Thank you for sharing with us, and we sincerely hope you will continue to update or post other articles
    http://...elsnow.com

  104. Much obliged to you so much Love your online journal..

  105. best lapt... | best laptop for college students |

    Choosing the <a href="http://...t;>best laptop for college students</a> under $500 is not that easy especially if you are looking for high end features or want to use the laptop for gaming.

  106. designer... | designer womens shoes |

    Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it.

  107. bliherbal... | bliherbal online store |

    I really enjoy simply browsing all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a fantastic article. The information that you have provided is actually very beneficial. http://...0Ditemukan

    Just keep write what you are passionate about, and the readers will come to your posting. http://.../show/1204

    Very nice article. I just bookmark your page and want to says that I have truly enjoyed surfing your weblog posts. Thanks alot : ) http://...s/show/443

    This article gives the light in which we can possibly see the reality. This is very nice one and gives indepth information. Thanks alot : ) for this good article. http://...a-operasi/

    In a college thesis for research I've got to search sites with relevant information on given topic and give them to teacher our opinion and the article. Your article helped me a lot. http://...st/1440727

    This is my first time see here. From the tons of comments on your articles, I suppose I'm not just one having all the enjoyment in this article! http://...55201.html

    I just couldn't leave your website before telling you that I truly enjoyed the top quality articles you present for your visitors? Will be returning again frequently to check up on brand new article. http://...st/1439069

    Your publish had provided me with another point of view on this topic. I had no concept that things can work with this ways as well. Thank you for sharing your opinion. https:/...-Stadium-4

    I want to thank you for your perfectly written content its useful and your writing concept helped me to that without any difficulty. Credit https:/...stadium-4/

  108. This is an awesome motivating article.I am practically satisfied with your great work.You put truly extremely accommodating data. Keep it up. Continue blogging. Hoping to perusing your next post.

  109. Phenomenal and extremely energizing site. Adoration to watch. Continue Rocking.

  110. Tubemate gives you full access to download the youtube videos easily with just one click.

  111. A debt of gratitude is in order For sharing this Superb article.I utilize this Article to demonstrate my task in college.it is helpful For me Great Work.

  112. How To Ki... | How To Kiss A Man To Make Him Fall In Love |

    I gotta most loved this site it appears to be extremely useful .

  113. Your music is astounding. You have some extremely capable specialists. I wish you the best of accomplishment.

  114. Questions... | Questions To Ask A Guy Over Text |

    That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea. thanks once more.

  115. I as of late discovered numerous helpful data in your site particularly this online journal page. Among the loads of remarks on your articles. Much obliged for sharing.

  116. This is such an incredible asset, to the point that you are giving and you give it away for nothing. I cherish seeing blog that comprehend the quality. Im happy to have discovered this post as its such an intriguing one! I am dependably watchful for quality posts and articles so i assume im fortunate to have discovered this! I trust you will be including more later on...

  117. Our postcards founder the champion measure for your money. spotting which you uncomparable can decide what's foremost to your needs, hot Prints hit organized our products in this type of manner that they are able to reconcile full customization.

  118. I truly appreciated perusing this post, huge fan. Keep doing awesome me when would you be able to distribute more articles or where would I be able to peruse more on the subject?

  119. i read a considerable measure of stuff and i found that the method for composing to clearifing that precisely need to say was great so i am awed and ilike to come back again in future..

  120. Your work is great and I welcome you and bouncing for some more useful posts. Much obliged to you for sharing incredible data to us.

  121. I am really glad to see you in the recent updates in this blog categories and I hope you guys come up with more new things soon.

  122. This tutorial is very useful to provide web service with ZendFramework. Thanks for sharing informative article with us.