Home » Php » Can't generate XML through WSDLDocument.php (PHP SOAP)

Can't generate XML through WSDLDocument.php (PHP SOAP)

Posted by: admin October 21, 2018 Leave a comment

Questions:

I have a simple server/client SOAP interaction with a Shop class (shop.php) commented like this:

<?php

/** 
 * Class Shop
 * Objective: Handling my shop
 * 
 * @author Me
 */ 

require_once('config.php');
include("product.php");
include("fruit.php");

class Shop{

    /** 
     * Returns a string with family's products concatenated
     * 
     * @param string $familyId
     * @return string
     * 
     */ 
    public static function getFamilyProducts($familyId){

Now I puy my WSDLDocument.php next to my class (all files are in the same folder), and write my WSDLgenerator.php:

<?php
require_once('shop.php');
require_once('WSDLDocument.php');

$url = "http://localhost/Shop/server.php";
$uri = "http://localhost/Shop";

$wsdl = new WSDLDocument( "Shop", $url, $uri  );
echo $wsdl->saveXml();
?>

My server is serving flawlessly to my client but here it is anyway if you want to check:

<?php
require_once('shop.php');
$uri = 'http://localhost/Shop';

$server = new SoapServer(null, array('uri' => $uri));
$server -> setClass('Shop');
$server -> handle();
?>

When I access WSDLGenerator.php it is printing “Class Shop Objective: Handling my shop” but nothing more. Browser’s inspector is getting the class name and that lines:

<wsdl:service name="Shop">
<wsdl:documentation>Class Shop Objective: Handling my shop
</wsdl:documentation>
...

There are some calls to Shop (“ShopPortType”, “ShopBinding”, “ShopPort”) but there’s no signal of my functions and its parameters…

Answers: