SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Member NALF's Avatar
    Join Date
    May 2004
    Location
    Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with XMLRPC for pHp

    Hi!
    I am a M$ guy and I now need to access a .NET web service using a client on a FREE linux web host (using php4).
    Having very few information and support about the current Linux host phpinfo() tell me that it supports xmlrpc-epi v. 0.51.
    Now what?
    I tried to understand the DOC at http://xmlrpc-c.sourceforge.net/xmlr...hp-client.html

    with no luck!
    I am stuck at the very beginning where I have to include xmlrpc!!
    the code:

    <?php
    include 'xmlrpc.inc';
    ?>

    The error:
    Fatal error: main(): Failed opening required 'xmlrpc.inc' (include_path='./') in /data/hosted/johnwinner/index.php on line 5

    Could you please help me to get started the right way?!
    The doc tell me to do that but it doesnt work.
    How do I know the include path?
    How do I know if the xmlrpc.inc is not named xmlrpc.php or something different?
    If you have any better, simple way to access a .NET web service (.asmx) using very basic PHP please tell me.
    Thank you very much!

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That error is saying that xmlrpc.inc isn't in teh same directory as the PHP file. Are they?

  3. #3
    SitePoint Member NALF's Avatar
    Join Date
    May 2004
    Location
    Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course no but It is supposed to be installed on the server. What I need to know is how to use the installed version?
    thank you!

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, to be honest, I've never used that class. I have used this one though: http://www.keithdevens.com/software/xmlrpc/source.php It seems to work fine. Example here: http://www.sitepoint.com/article/own...-php-xml-rpc/4

  5. #5
    SitePoint Member NALF's Avatar
    Join Date
    May 2004
    Location
    Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So if I download the source save it as PHP will I be able to use it on my free host??

  6. #6
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah.

  7. #7
    SitePoint Member NALF's Avatar
    Join Date
    May 2004
    Location
    Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hello!
    Me again!
    After trying the Keith Devens implementation still no success...
    For the purpose of my tests I set up a very basic "Hello World" Web Service with only 1 Web Method named "HelloWorld".
    The first error occured when I tried to use my domain name "test.specialnet.biz". I switched to IP address since it always throw a connectivity error with the domain name. BTW this is a shared ip...
    Here what I tried after:

    <?php

    include("xmlrpc.php");
    define("XMLRPC_DEBUG", 1);

    $msg='<soap:Envelope xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xmlnssd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><HelloWorld xmlns="http://namespace/" /></soap:Body></soap:Envelope>';

    $response = XMLRPC_request('209.132.227.61', '/test.asmx' , 'HelloWorld');print_r($response);
    $response = XMLRPC_request('209.132.227.61', '/test.asmx' , '$msg');print_r($response);
    $response = XMLRPC_request('209.132.227.61', '/test.asmx' , $msg);print_r($response);

    $response = XMLRPC_request('209.132.227.61', '/test.asmx?op=HelloWorld' , 'HelloWorld');print_r($response);
    $response = XMLRPC_request('209.132.227.61', '/test.asmx?op=HelloWorld' , '$msg');print_r($response);
    $response = XMLRPC_request('209.132.227.61', '/test.asmx?op=HelloWorld' , $msg);print_r($response);
    ?>

    All the variations up there display the same results:
    Array ( [0] => 1 [1] => )

    Any idea someone?
    Thank you for your time!

  8. #8
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you aware of the runtime error at http://209.132.227.61/test.asmx ?

  9. #9
    SitePoint Member NALF's Avatar
    Join Date
    May 2004
    Location
    Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes just figured out that since it is shared IP I MUST use the domain name to access it...
    I'll try some things and post results...

  10. #10
    SitePoint Member NALF's Avatar
    Join Date
    May 2004
    Location
    Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    Ok I finally succeeded consuming my .NET Web Service with the KB implementation of xmlrpc for PHP.
    I will list the problem encountered and the solutions I found so maybe this can help other people in the future...

    If you try Keith Devens' code in the original version like this:

    $response = XMLRPC_request('domain.com', '/test.asmx' ,"TestMethod");

    this will "seem" to succeed and return :

    Array ( [0] => 1 [1] => )

    You will never see the proper result in the array.
    The reason is:
    1 - .NET Web Service require a special HEADER entry so it can works correctly
    2 - the returned SOAP message tags are not the same as the original implementation of xmlrpc

    Solutions:
    1 - the special header is called "SOAPAction" and you should add it as follow:

    SOAPAction: "http://myNameSpace/myMethod"

    (don't forget the ")

    2 - in the original script you can find ths line (always in the XMLRPC_Request method):

    $return = array(true, XMLRPC_adjustValue(&$data['methodResponse']['params']['param']['value']));

    For .NET Web Service to work I had to replace it with this one:

    $return = array(true, XMLRPC_adjustValue(&$data["soap:Envelope"]["soap:Body"][$methodName . "Response"][$methodName . "Result"]));

    This is it.
    For those interested I wrote a special version of XMLRPC_request called XMLRPC_request_DotNet specially to call .NET Web Services. You can PM me if you would like to have it.
    I do not publish it here since this is very unofficial and it sure is full of bugs but it seem to work very well with my Web Services.

    Thank you someonewhois for the help!


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
  •