WSDL2PHP generates anonymous classes

johan's picture

When I generate code from the WSDL below I end up with anonymous classes in the php code. Does anyone know the reason for this or how to fix it?

Modifying the bookmark schema and changing refs attributes to name and type attributes is not an acceptable solution although it works. I've tried both versions, 2.0.0 and the latest SVN version, but none of them seems to work.

Generated php code

<?php

// PHP classes corresponding to the data types in defined in WSDL

class setBookmarks {

    /**
     * @var string
     */
    public $contentID;

    /**
     * @var (object)anonymous0
     */
    public $bookmarkSet;

}

class anonymous0 {

    /**
     * @var (object)anonymous1
     */
    public $title;

    /**
     * @var string
     */
    public $uid;

}

class anonymous1 {

    /**
     * @var string
     */
    public $text;

}

class setBookmarksResponse {

    /**
     * @var boolean
     */
    public $setBookmarksResult;

}

// define the class map
$class_map = array(
    "setBookmarks" => "setBookmarks",
    "anonymous0" => "anonymous0",
    "anonymous1" => "anonymous1",
    "setBookmarksResponse" => "setBookmarksResponse"); 

...

?>

WSDL

<definitions name="DAISYOnlineService" targetNamespace="http://www.daisy.org/ns/daisy-online/" xmlns="http://schemas.xmls
oap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.daisy.org/ns/daisy-online/">

    <types>
        <xs:schema targetNamespace="http://www.daisy.org/ns/daisy-online/" elementFormDefault="qualified" attributeFormDe
fault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:daisy="http://www.daisy.org/z3986/2005/bookmark/">

        <xs:import namespace="http://www.daisy.org/z3986/2005/bookmark/" schemaLocation="bookmark-2005-1.xsd"/>

        <xs:element name="setBookmarks">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="1" maxOccurs="1" name="contentID" type="xs:string"/>
                    <xs:element minOccurs="1" maxOccurs="1" ref="daisy:bookmarkSet"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>

        <xs:element name="setBookmarksResponse">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="1" maxOccurs="1" name="setBookmarksResult" type="xs:boolean"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>

    </xs:schema>
    </types>

    <message name="setBookmarks_inputMessage">
    <part name="parameters" element="tns:setBookmarks"/>
    </message>

    <message name="setBookmarks_outputMessage">
    <part name="parameters" element="tns:setBookmarksResponse"/>
    </message>

    <portType name="daisy-online">
        <operation name="setBookmarks">
        <input message="tns:setBookmarks_inputMessage"/>
        <output message="tns:setBookmarks_outputMessage"/>
        </operation>
    </portType>

    <binding name="DaisyOnlineService" type="tns:daisy-online">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="setBookmarks">
            <soap:operation soapAction="/setBookmarks" style="document"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>

    <service name="Daisy_Online_Service">
        <port name="HTTP" binding="tns:DaisyOnlineService">
            <soap:address location="http://anyURI/service.php"/>
        </port>
    </service>

</definitions>


Schema

<xs:schema id="bookmark-2005-1" xmlns="http://www.daisy.org/z3986/2005/bookmark/" targetNamespace="http://www.daisy.org/z
3986/2005/bookmark/" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="bookmarkSet">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="title"/>
                <xs:element ref="uid"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="title">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="text"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="uid" type="xs:string" />

    <xs:element name="text" type="xs:string" />

</xs:schema>
johan's picture

created a path to fix the problem

I've been analyzing the source code a found a fix for my issue. The simple patch below (only added a single row) worked for my service but in other cases it might not work.

Patch
--- wso2-wsf-php-src-2.0.0_org/scripts/dynamic_invocation/xslt/wsdl2sig.xslt    2008-09-11 10:50:05.000000000 +0300
+++ wso2-wsf-php-src-2.0.0/scripts/dynamic_invocation/xslt/wsdl2sig.xslt    2010-01-21 14:09:59.000000000 +0200
@@ -1232,6 +1232,7 @@
                                 </xsl:choose>
                             </xsl:when>
                             <xsl:otherwise>
+                                <xsl:attribute name="type"><xsl:value-of select="$this-element/@name"/></xsl:attribute>
                                 <!-- This is when elements have anonymous types -->
                                 <xsl:for-each select="./*">
                                     <xsl:call-template name="infer-types">
mundumelga.gmail.com's picture

This definitely solved the

This definitely solved the issue. I had the same problem and the php deserializer kept giving me this object WSFUnknownSchemaConstruct. This bug could be fixed if there's to be a next version.
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)