SitePoint Sponsor

User Tag List

View Poll Results: How far have you got with PHP and Web Services?

Voters
92. You may not vote on this poll
  • I've built an XML-RPC client for a web service

    15 16.30%
  • I've built my own XML-RPC server

    17 18.48%
  • I've built an SOAP client for a web service

    15 16.30%
  • I've built my own SOAP server

    9 9.78%
  • I can't see a reason to use web services

    15 16.30%
  • I don't understand the technology and concepts involved

    36 39.13%
  • What's a web service?

    21 22.83%
Multiple Choice Poll.
Page 2 of 4 FirstFirst 1234 LastLast
Results 26 to 50 of 77
  1. #26
    SitePoint Addict five40's Avatar
    Join Date
    Jul 2001
    Location
    Imatra, Finland
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by HarryF

    Simply put, click on "Full List" at XMethod, one of the primary free web service registries. Not that long, is it?
    ... or take a look at Salcentral (most of them are free).
    "-Surely you can't be serious ?
    -Yes I am serious...and don't call me Shirley."

  2. #27
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Harry,

    I admire you as a programmer, and your passion about these things is definitely contagious.....but your article totally lost me, bro. I want to learn this stuff but it is sooo confusing to me. I conceptually understand it all, but when it comes down to details, I'm totally lost. I guess I don't understand XML well enouh....and I AM a programmer.

    Aaron
    Aaron Brazell
    Technosailor



  3. #28
    Non-Member Siltrince's Avatar
    Join Date
    Aug 2001
    Location
    Belgium
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for answering HarryF but like Sketch I'm still lost ( btw I know the basics of C and just started with PHP and MySQl)

  4. #29
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - gonna need specific example of things you're having trouble with but here's a few things in general to help conceptualize.

    - Think of a web service like a database. You query a database and it gives you back some variables, such as an array. You send a message to a web services saying "Give me this data" - it responds with the variables you want. You can then do something like display a table as you would with the results of a web page.

    - Don't worry about the XML too much. Most of the good PHP libraries handle all the XML stuff for you. All you need to be concerned with is passing to receiving some PHP variables to and from the library (which should convert them to XML).

    - Take an array like;

    PHP Code:
    $array = array ( "red""green""blue" ); 
    Using Keith Devens library;

    PHP Code:
    <?php
    /* Include the library */
    include ( "kd_xmlrpc.php" );


    $array = array ( "red""green""blue" );

    $xml XMLRPC_prepare $array );

    $xml XML_serialize $xml );

    echo (
    $xml);
    ?>
    The array becomes XML which looks like;

    Code:
    <?xml version="1.0" ?>
    <array>
    	<data>
    		<value>
    			<string>red</string>
    		</value>
    		<value>
    			<string>green</string>
    		</value>
    		<value>
    			<string>blue</string>
    		</value>
    	</data>
    </array>
    You can now send that XML over the Internet, using HTTP, and gather it somewhere else, using a client, which can then convert the XML back into PHP variables. Within a single script we can do this;

    PHP Code:
    <?php
    /* Include the library */
    include ( "kd_xmlrpc.php" );


    $array = array ( "red""green""blue" );

    $xml XMLRPC_prepare $array );

    $xml XML_serialize $xml );

    echo (
    $xml);

    /* Send over the Internet via HTTP here */

    $array XML_unserialize $xml );

    echo ( 
    "<br /><pre>" );
    print_r ($array);
    echo ( 
    "</pre>" );
    ?>
    We took and array, converted it to XML, "send it over the Net" then converted the XML back into a PHP array. The way we then treat the array can then be just like an array we get from MySQL.

    - On the HTTP front, PHP is capable of acting just like a web browser does, fetching web pages from other websites. With web services, instead of fetching an HTML web page, instead is fetchs a page of XML.

    Try some the script here: http://www.hotscripts.com/PHP/Script.../Web_Fetching/

    Getting any better?

  5. #30
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that was better. Your first point was moot. I understand the concept. No problem there. What I wasn't getting was the fact that I didn't have to write the XML. Thanks.

    Sketch
    Aaron Brazell
    Technosailor



  6. #31
    will code HTML for food Michel V's Avatar
    Join Date
    Sep 2000
    Location
    Corsica
    Posts
    552
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Be careful with international users and web services in PHP.
    It turns out PHP's XML parser or functions can only handle ISO-8859-1, UTF8, and then another encoding format that I can't remember at the moment. So sometimes the script may reply with an error when the user used special characters.
    I've seen this happening randomly with brazilian users who used tildas for words like 'não' and then saw a XML parsing error...

    I thought it was a problem with UsefulInc's XMLRPC server classes, but it's actually a problem with PHP itself

  7. #32
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you create a bug report for that Mr Ma?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  8. #33
    will code HTML for food Michel V's Avatar
    Join Date
    Sep 2000
    Location
    Corsica
    Posts
    552
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would, but it would be redundant:
    This PHP extension implements support for James Clark's expat in PHP. This toolkit lets you parse, but not validate, XML documents. It supports three source character encodings also provided by PHP: US-ASCII, ISO-8859-1 and UTF-8. UTF-16 is not supported.
    http://fr.php.net/manual/en/ref.xml.php (for some reason, the www. version wouldn't load)
    Last edited by Michel V; Aug 14, 2002 at 16:33.
    [blogger: zengun] [blogware contributor: wordpress]

  9. #34
    SitePoint Member
    Join Date
    Aug 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Too bad your code does not work!

    Sorry for the flame - but I have just spent the ENTIRE week looking at your code along with Keith Devens code and im still getting errors.

    I have contacted you for help and your quick pass through your code and quick fix of modifying the "HarryFXMLRPC" to be " 'HarryFXMLRPC' " didnt fix what I was asking you.

    Here is a note to anyone looking to post articles on the web: PLEASE TEST YOUR CODE RELEASE BEFORE POSTING IT AS AN EXAMPLE FOR ANYONE!

    -Going back to being frustrated looking through your code..
    Steve

    [UPDATE] - I have found the bug which kept me from using this library. WOW! It workds great now. Basically, the error was centered around the function call 'XML_unserialize(&$xml)'. It assumed that the following fields were being sent in the XML dataset:
    $level = $value['level'];
    $type = $value['type'];
    $tag = $value['tag'];
    $val = $value['value'];
    $attributes = $value['attributes'];

    See the last line?:
    '$attributes = $value['attributes'];'

    NO ATTRIBUTES ARE BEING ASSIGNED IN THE XML DATASET BEING PASSED!!

    Here is the fix for this bug:
    (around line # 145 in source.php/kd_xmlrpc.php from Keith Devens website)

    [..cut..]

    $level = "";
    $type = "";
    $tag = "";
    $val = "";
    $attributes = "";

    for($n = 0; $n<$value_count; $n++)
    {

    $value = $values[$n];

    //echo print_r($value);

    if(isset($value['level']))
    $level = $value['level'];

    if(isset($value['type']))
    $type = $value['type'];

    if(isset($value['tag']))
    $tag = $value['tag'];

    if(isset($value['value']))
    $val = $value['value'];

    if(isset($value['attributes']))
    $attributes = $value['attributes'];

    [../cut..]


    Thats that! Now on to making web services work for me!
    For all FIXED source code, go here:
    http://home.nycap.rr.com/sbrassard/c...xmlrpc_fix.zip
    Steve Brassard
    sbrassar@nycap.rr.com
    Last edited by SBrassard; Aug 29, 2002 at 11:58.

  10. #35
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If anyone's interested I've just released a simple but functional XML-RPC library. It was written for the latest version of PHP so it should work straight out of the box (without firing any notices or warnings even with strict error reporting turned on).

    http://scripts.incutio.com/xmlrpc/

    Be warned, it's the first release of the library. Drop me a line if you run in to any problems

  11. #36
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Stephen,

    Apologies for not having been more useful. You caught me at a time of being extremely busy. I'm gonna have a big delve into this tomorrow AM, and fix whatever bugs there are in that article.

    There's about 10 issues happening all at once, which is why I opened up this thread in the first place and glad you've picked this up - Keith contacted me to let me know he'd updated his code the very day (by coincidence) the article was published.

    Realise now that what I'm guilty of is having written that code with PHP's error reporting too low and I promise I did fully bug test 'til PHP gave no errors but it now seems I didn't pick them all up.

    Anyway - in depth technical look tomorrow.

    Just as a matter of interest, can you tell me more about your PHP configuration - what error reporting you have, PHP version and in particular, the details of your XML Expat config. If you use the phpinfo() function, what I need is the part that looks like this;

    XML Support active
    XML Namespace Support active
    EXPAT Version 1.95.2

  12. #37
    SitePoint Member
    Join Date
    Aug 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by HarryF
    Hi Stephen,

    Apologies for not having been more useful. You caught me at a time of being extremely busy. I'm gonna have a big delve into this tomorrow AM, and fix whatever bugs there are in that article.

    Hey, its understandable.. But I do have to say that as good as your article was and also as helpful and insightful it has been to me and others, it was also very frustrating not being able to download it and have it JustWork(TM).



    Just as a matter of interest, can you tell me more about your PHP configuration - what error reporting you have, PHP version and in particular, the details of your XML Expat config. If you use the phpinfo() function, what I need is the part that looks like this;

    Sure! I run Win2000 with Apache 1.3.26 and PHP v4.1.3dev. I havent updated it because its running fine. The XML parser reported in my phpinfo() function is:

    XML Support active
    XML Namespace Support active
    EXPAT Version 1.95.2

    Also, i am running mySQL v3.23.39. Please feel free to look at the code change that I made in an earlier post. I think this would come in handy. Also, turn your error_reporting variable your PHP.INI file set to 2047 or "E_ALL".

    //Steve

  13. #38
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - checked out Keith's latest code as well and he's fixed that bug as well, so I've updated Georgina (the SP Editor) with a fixed version.

    What I was particularily disturbed to discover (having taken Vincents advice since that article) is you switch this off in tyour php.ini;

    Code:
    allow_call_time_pass_reference = On
    You get a whole load more errors, as Keith passes these kind of references alot. Think we'll need to wait for Skunks new library...

  14. #39
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a side note: anyone wondering why they're having a hard time understanding web services, check this - seven "top" people in IT give different definitions.

  15. #40
    SitePoint Member
    Join Date
    Aug 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by HarryF
    OK - checked out Keith's latest code as well and he's fixed that bug as well, so I've updated Georgina (the SP Editor) with a fixed version.
    Great. Glad I could help. However, I have come across another minor bug which can poop out an error if not handled correctly.

    If the $site variable is not set with a port number, it can cause an error. At least, it did in my case.

    Take a look...


    Code:
    function XMLRPC_request($site, $location, $methodName, $params = NULL, $user_agent = NULL){
    	list($site, $port) = explode(':', $site);
    	if(!is_numeric($port)){
    		$port = 80;
    	}
    Should read:

    Code:
    function XMLRPC_request($site, $location, $methodName, $params = NULL, $user_agent = NULL){
    	if( strpos($site, ":") == 0 ){
                  $port = 80;
             }else{
                  list($site, $port) = explode(':', $site);
    	      if(!is_numeric($port)){
    		$port = 80;
    	      }
            }
    Just something that may fix any error that is cased by the $site variable.


    //Steve

  16. #41
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Harry,

    I just finished a client for your new web service, made completely in flash MX. Thought you might like to see the fruits of your labor to some extent.

    http://www.irq11.com/~louie/webService/flashClient.html

    Good Article BTW!
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  17. #42
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Holy K! That's awesome! And thanks for the compliment

    Really good to see someone taking it the next level. My own wish is for infinite time - every day there's another idea for something that's not being done right now, which XML-RPC or SOAP makes possible.

    This raises an interesting point though - in developing web services, it become increasingly important to seperate data and application login from presentation, as Louie demonstrates.

    A site can easily have multiple front ends; HTML, Flash, XML etc all sitting on top of the same database and logic. Once you reach that point, it's pretty easy (because your design allows it) to put in another web service "layer" below the user interface, allow it to be put on any website anywhere.

    Recently been playing with this PHP <a href="http://www.ros.co.nz/pdf/">PDF class</a> (requires no extension) - would no doubt be real easy to provide another interface based on PDF output.

  18. #43
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Freddy,

    When I click the link I get a blank page with a Flash placeholder. No interface or anything.... What's the deal?

  19. #44
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not working now, but it was before

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  20. #45
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flash 6 player needed.

    Thanks Harry, I plan on doing some more playing tonight.

    Could you shoot a working copy of the web service code to me at louie@irq11.com, the one that one can download from the article is erroring out, saying the $response array is empty.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  21. #46
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, Louie it worked, then it didn't, now it does! When it didn't work it just had the top and left hand border and nothing else

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  22. #47
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I am screwing with the server script, so it may be off an on for a while.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  23. #48
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Web Services rule!!!!!!!!!!!! Thanks HarryF for the start on what is going to be no doubt an adventerous ride. Here is another one I just whipped up. It can retrieve ebay items and shwo details about the items, all using web services and flash MX,
    http://www.irq11.com/~louie/webServi...shClient2.html
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  24. #49
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks awesome Freddy

    I'm reading the article for the second time trying to figure all of this out
    Mike
    It's not who I am underneath, but what I do that defines me.

  25. #50
    SitePoint Guru marcel's Avatar
    Join Date
    Nov 2000
    Posts
    920
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I like the idea that my xml services can be "register" in a "directory".

    http://phpsoaptoolkit.sourceforge.net/phpsoap/ has a few PHP SOAP examples...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •