NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Nusoap Web services

Joined: 20 Sep 2016
Posts: 1
Reply with quote
Dear all,

I try to do a web service (server and client) on a Linux VPS (Debian 6 Squeeze). I use the PHP Version 5.3.3-7+squeeze27.
Here is my server (ws.php)

require_once "lib/nusoap.php";
class food {
    public function getFood($type) {
        switch ($type) {
            case 'starter':
                return 'Soup';
            case 'Main':
                return 'Curry';
            case 'Desert':
                return 'Ice Cream';
$server = new soap_server();
$server->configureWSDL("foodservice", "");
    array("type" => "xsd:string"),
    array("return" => "xsd:string"),
    "Get food by type");

and here is my client (client.php)

require_once "lib/nusoap.php";
$client = new nusoap_client("food.wsdl", true);
$error  = $client->getError();
if ($error) {
    echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
$result = $client->call("food.getFood", array("type" => "Main"));
if ($client->fault) {
    echo "<h2>Fault</h2><pre>";
    echo "</pre>";
} else {
    $error = $client->getError();
    if ($error) {
        echo "<h2>Error</h2><pre>" . $error . "</pre>";
    } else {
        echo "<h2>Main</h2>";
        echo $result;
// show soap request and response
echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

I saved the wsdl file that I generated with the server (

<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC="" xmlns:tns="" xmlns:soap="" xmlns:wsdl="" xmlns="" targetNamespace="">
        <xsd:schema targetNamespace="">
            <xsd:import namespace="" />
            <xsd:import namespace="" />
    <message name="food.getFoodRequest">
        <part name="type" type="xsd:string" />
    <message name="food.getFoodResponse">
        <part name="return" type="xsd:string" />
    <portType name="foodservicePortType">
        <operation name="food.getFood">
            <documentation>Get food by type</documentation>
            <input message="tns:food.getFoodRequest"/>
            <output message="tns:food.getFoodResponse"/>
    <binding name="foodserviceBinding" type="tns:foodservicePortType">
        <soap:binding style="rpc" transport=""/>
        <operation name="food.getFood">
            <soap:operation soapAction="" style="rpc"/>
                <soap:body use="encoded" namespace="" encodingStyle=""/>
                <soap:body use="encoded" namespace="" encodingStyle=""/>
    <service name="foodservice">
        <port name="foodservicePort" binding="tns:foodserviceBinding">
            <soap:address location=""/>

When I try to consume the Web Service with my client, I have this error message:


HTTP Error: Unsupported HTTP response status 404 Not Found (soapclient->response has contents of the response)


POST /ws.php HTTP/1.0
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""

Do you have an idea?

Thanks in advance for your help.
Content-Length: 571[/quote]
View user's profileFind all posts by Vianney03Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8338
Reply with quote
404 means -- wrong URL in your SOAP request.

The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Nusoap Web services
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

 Reply to topic