SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: PHP5 SOAP Extension - WTF

  1. #1
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP5 SOAP Extension - WTF

    I just enabled the PHP5 soap extension on my installation, in order to use the SoapServer and SoapClient classes to work my way through some example code that I've got. Only problem is that I keep getting this error (considering I have no code experience with SOAP, only all that I've read, which isn't PHP-Specific):

    Code:
    <SOAP-ENV:Envelope>
        <SOAP-ENV:Body>
            <SOAP-ENV:Fault>
                <faultcode>SOAP-ENV:Server</faultcode>
                <faultstring>Bad Request. Can't find HTTP_RAW_POST_DATA</faultstring>
            </SOAP-ENV:Fault>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Looks like I'm getting an entire SOAP envelope as a response... Only problem is that this is my server. Here's my PHP code (taken from the Zend tutorial):

    PHP Code:
    <?php 
    $quotes 
    = array( 
      
    "ibm" => 98.42 
    );   

    function 
    getQuote($symbol) { 
      global 
    $quotes
      return 
    $quotes[$symbol]; 


    ini_set("soap.wsdl_cache_enabled""0"); // disabling WSDL cache 
    $server = new SoapServer("stockquote.wsdl"); 
    $server->addFunction("getQuote"); 
    $server->handle();
    ?>
    All of the files are there and everything.

    WTF?
    Ryan

  2. #2
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No one?
    Ryan

  3. #3
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tried the SOAP client with one of the PHP5 RCs per the code in the article and it worked fine. Have not yet played with using it for a server.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  4. #4
    SitePoint Addict pointbeing's Avatar
    Join Date
    Jun 2004
    Location
    London, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps this is the same issue as:

    http://www.sitepoint.com/forums/showthread.php?t=171680

    I just came across these in the search when I was looking for something else entirely

  5. #5
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need help, I tried with this simple code to create a web service
    PHP Code:
    <?php # HelloServer.php
    # Copyright (c) 2005 by Dr. Herong Yang
    #
    function hello($someone) { 
       return 
    "Hello " $someone "!";

       
    $server = new SoapServer(null
          array(
    'uri' => "urn://www.herong.home/res"));
       
    $server->addFunction("hello"); 
       
    $server->handle(); 
    ?>
    But it reuslt was HTTP 500 Internal server Error
    I using php5 in xampp package
    Please help me
    Thanks

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know why you get an error message, but I have been playing around with the same thing and this code works for me. Just update the location in $options and make sure that the Test class is included in the server file.

    Client:

    PHP Code:
    <?php
    $options 
    = array(
    'location'=>'http://localhost/akkreditering/wwwdocs/soap/server.php',
    'uri'=>'http://localhost/akkreditering/wwwdocs/soap/server/',
    );

    try {
        
    $client = new SoapClient(null,$options);
        echo 
    $client->getString();    

    }
    catch ( 
    SoapFault $e ){
        echo 
    $e->getMessage();
    }
    ?>
    Server:

    PHP Code:
    <?php
    $options 
    = array('uri' => 'http://localhost/akkreditering/wwwdocs/soap/server/');
    $server = new SoapServer(null,$options);
    $server->setClass('Test');
    $server->handle();
    ?>
    Test class:
    PHP Code:
    <?php
    class Test{
        public function 
    getString(){
            return 
    'Hello World!!';
        }    
    }
    ?>

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
  •