1

I'm quite new to webservices and soap, and I followed a tutorial and came with this code:

SOAP Server :

<?php
include("lib/nusoap.php");
include("getDB.php");

function getUsers()
{
    $user_id = $_GET['user_id'];
    $result = mysql_query("SELECT * FROM -table name- WHERE user_id = '$user_id'");
    $try    = mysql_fetch_array($result);
    return join(",", array(
        $result['username'], $result['password']
    ));
}

$server = new soap_server();
$server->register("getUsers");
$server->service($HTTP_RAW_POST_DATA);
?>

SOAP Client :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title></title>

      <!-- Error Reporting -->
      <?php 
         error_reporting(E_ALL);
         ini_set('display_errors', '1'); 
      ?>
   </head>
   <body>
        <?php
            include("lib/nusoap.php");
            $client = new nusoap_client("http://localhost/wp-content/themes/blackbird/phpwizard/HTML5Application/public_html/Webservice.php?user_id=4");

            $error = $client->getError();

            if ($error) 
            {
                echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
            }

            $result = $client->call("getUsers", array("category" => "books"));   

            if ($client->fault) 
            {
                echo "<h2>Fault</h2><pre>";
                print_r($result);
                echo "</pre>";
            }

            else 
            {
                $error = $client->getError();

                if ($error) 
                {
                    echo "<h2>Error</h2><pre>" . $error . "</pre>";
                }

                else 
                {
                    echo "<h2>Books</h2><pre>";
                    echo $result;
                    echo "</pre>";
                }
            }

        ?>
    </body>
</html>

Now when loading the SOAP client I'm getting the error:

XML error parsing SOAP payload on line 3: Reserved XML Name

I have no idea why this is happening.

1
  • Which tutorial did you follow? What have you done to better understand the error message? What did you expect differently than the error message? What makes your question different to XML error parsing SOAP payload: Reserved XML Name? Commented May 21, 2013 at 16:59

1 Answer 1

2

Try to Remove the whitespace before <?xml as mentioned in this question
XML error parsing SOAP payload: Reserved XML Name

Also is it possible to paste the dump of the NuSOAP client, just like in that question so we can see whats being rendered. Lets start the debugging there and respond with what you see on your example.

Additionally, here is a tutorial that I have used in the past. Php by itself works well with SOAP so give that a try before adding in a layer of a separate library unless you need anything fancy from it. Try this example to see if it works for you.
IBM Opensource Php SoapServerClient example.

Sign up to request clarification or add additional context in comments.

3 Comments

This all looks more like a comment than an answer.
"Try to Remove the whitespace before <?xml as mentioned in this question" . Thats the answer right there
You don't need to duplicate an existing answer then if that is your answer. Just leave a link in a comment and see if that's the solution already. If so, the question is a duplicate anyway.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.