axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Preston <PREST...@uk.ibm.com>
Subject Specific WSDL2WS problem
Date Tue, 29 Jun 2004 19:57:56 GMT
Hi All,
        I have got a specific WSDL2WS problem that  need help with.  In 
the following example, the find_business operation has an element type of 
name.  The associated xsd defines name as a complexType with 
simpleContent.  When the class of this type is generated by the WSDL2WS 
tool, the class does not contain and data types to hold either the name 
value (a string) and the optional attribute lang (a string?).  Here is a 
part of the WSDL...

INQUIRE_V2.WSDL
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"...>
        <message name="find_business">
                <part name="body" element="uddi:find_business" />
        </message>
        :
        <portType name="Inquire">
                <operation name="find_business">
                        <input message="tns:find_business" />
                        <output message="tns:businessList" />
                        <fault name="error" message=
"tns:dispositionReport" />
                </operation>
        :
        </portType>
        <binding name="InquireSoap" type="tns:Inquire">
                <soap:binding style="document" transport=
"http://schemas.xmlsoap.org/soap/http" />
                <documentation>This is the SOAP binding for the UDDI 
inquiry operations.</documentation>
                :
                <operation name="find_business">
                        <soap:operation soapAction="find_business" style=
"document" />
                        <input>
                                <soap:body parts="body" use="literal" 
namespace="urn:uddi-org:api_v2" />
                        </input>
                        <output>
                                <soap:body parts="body" use="literal" 
namespace="urn:uddi-org:api_v2" />
                        </output>
                        <fault name="error">
                                <soap:fault name="error" use="literal" />
                        </fault>
                </operation>
        </binding>
</definitions>

UDDI_V2.XSD
<xsd:schema ...>
        <xsd:element name="find_business" type="uddi:find_business"/>
        <xsd:complexType name="find_business">
                <xsd:sequence>
                        <xsd:element ref="uddi:findQualifiers" minOccurs=
"0"/>
                        <xsd:element ref="uddi:name" minOccurs="0" 
maxOccurs="unbounded"/>
                        <xsd:element ref="uddi:identifierBag" minOccurs=
"0"/>
                        <xsd:element ref="uddi:categoryBag" minOccurs="0"
/>
                        <xsd:element ref="uddi:tModelBag" minOccurs="0"/>
                        <xsd:element ref="uddi:discoveryURLs" minOccurs=
"0"/>
                </xsd:sequence>
                <xsd:attribute name="generic" type="string" use="required"
/>
                <xsd:attribute name="maxRows" type="int" use="optional"/>
        </xsd:complexType>
        :
        <xsd:element name="name" type="uddi:name"/>
        <xsd:complexType name="name">
                <xsd:simpleContent>
                        <xsd:extension base="string">
                                <xsd:attribute ref="xml:lang" use=
"optional"/>
                        </xsd:extension>
                </xsd:simpleContent>
        </xsd:complexType>
</xsd:schema>

When the WSDL is parsed by the WSDL2WS stub generator, I would assume that 
the following code would result,

name.cpp
/*
 * This file was auto-generated by the Axis C++ Web Service Generator 
(WSDL2Ws)
 * This file contains functions to manipulate complex type name
 */

#include <malloc.h>
#include <axis/server/AxisWrapperAPI.h>

#include "name.h"
/*
 * This static method serialize a name type of object
 */
int Axis_Serialize_name(name* param, IWrapperSoapSerializer* pSZ, bool 
bArray = false)
{
        if ( param == NULL ) {
         /* TODO : may need to check nillable value*/
        pSZ->serializeAsAttribute("xsi:nil", 0, 
(void*)&(xsd_boolean_true), XSD_BOOLEAN);
         pSZ->serialize(">", NULL);
        return AXIS_SUCCESS;
        }
        /* first serialize attributes if any*/
        if (0 != param->lang)
                pSZ->serializeAsAttribute("lang", 0, 
(void*)&(param->lang), XSD_STRING);

        pSZ->serialize(">", NULL);

        pSZ->serialize( *param->value, NULL);

        return AXIS_SUCCESS;
}

/*
 * This static method deserialize a name type of object
 */
int Axis_DeSerialize_name(name* param, IWrapperSoapDeSerializer* pIWSDZ)
{
        *param->lang = pIWSDZ->getAttributeAsString("lang",0);

        pIWSDZ->getElementAsString(*param->value,NULL);

        return AXIS_SUCCESS;
}

void* Axis_Create_name(name* pObj, bool bArray = false, int nSize=0)
{
        if (bArray && (nSize > 0))
        {
                if (pObj)
                {
                        name* pNew = new name[nSize];
                        memcpy(pNew, pObj, sizeof(name)*nSize/2);
                        memset(pObj, 0, sizeof(name)*nSize/2);
                        delete [] pObj;
                        return pNew;
                }
                else
                {
                        return new name[nSize];
                }
        }
        else
                return new name;
}

/*
 * This static method delete a name type of object
 */
void Axis_Delete_name(name* param, bool bArray = false, int nSize=0)
{
        if (bArray)
        {
                delete [] param;
        }
        else
        {
                delete param;
        }
}
/*
 * This static method gives the size of name type of object
 */
int Axis_GetSize_name()
{
        return sizeof(name);
}

name::name()
{
        /*do not allocate memory to any pointer members here
         because deserializer will allocate memory anyway. */

        value = NULL; // Inserted by hand - WSDL2Ws will provide in the 
future
        lang = NULL; // Inserted by hand - WSDL2Ws will provide in the 
future
}

name::~name()
{
        /*delete any pointer and array members here*/
}

name.h
/*
 * This file was auto-generated by the Axis C++ Web Service Generator 
(WSDL2Ws)
 * This file contains functions to manipulate complex type name
 */

#if !defined(__NAME_PARAM_H__INCLUDED_)
#define __NAME_PARAM_H__INCLUDED_

#include <axis/server/AxisUserAPI.h>

/*Local name and the URI for the type*/
static const char* Axis_URI_name = "urn:uddi-org:api_v2";
static const char* Axis_TypeName_name = "name";

class name
{
public:
        xsd__string*    value; // Inserted by hand - WSDL2Ws will provide 
in the future
        xsd__string*    lang; // Inserted by hand - WSDL2Ws will provide 
in the future

        name();
        ~name();
};

#endif /* !defined(__NAME_PARAM_H__INCLUDED_)*/

But, instead I get...

name.cpp
/*
 * This file was auto-generated by the Axis C++ Web Service Generator 
(WSDL2Ws)
 * This file contains functions to manipulate complex type name
 */

#include <malloc.h>
#include <axis/server/AxisWrapperAPI.h>

#include "name.h"
/*
 * This static method serialize a name type of object
 */
int Axis_Serialize_name(name* param, IWrapperSoapSerializer* pSZ, bool 
bArray = false)
{
        pSZ->serialize(">", NULL);
        return AXIS_SUCCESS;
}

/*
 * This static method deserialize a name type of object
 */
int Axis_DeSerialize_name(name* param, IWrapperSoapDeSerializer* pIWSDZ)
{
        return AXIS_SUCCESS;
}

void* Axis_Create_name(name* pObj, bool bArray = false, int nSize=0)
{
        if (bArray && (nSize > 0))
        {
                if (pObj)
                {
                        name* pNew = new name[nSize];
                        memcpy(pNew, pObj, sizeof(name)*nSize/2);
                        memset(pObj, 0, sizeof(name)*nSize/2);
                        delete [] pObj;
                        return pNew;
                }
                else
                {
                        return new name[nSize];
                }
        }
        else
                return new name;
}

/*
 * This static method delete a name type of object
 */
void Axis_Delete_name(name* param, bool bArray = false, int nSize=0)
{
        if (bArray)
        {
                delete [] param;
        }
        else
        {
                delete param;
        }
}
/*
 * This static method gives the size of name type of object
 */
int Axis_GetSize_name()
{
        return sizeof(name);
}

name::name()
{
        /*do not allocate memory to any pointer members here
         because deserializer will allocate memory anyway. */
}

name::~name()
{
        /*delete any pointer and array members here*/
}

name.h
/*
 * This file was auto-generated by the Axis C++ Web Service Generator 
(WSDL2Ws)
 * This file contains functions to manipulate complex type name
 */

#if !defined(__NAME_PARAM_H__INCLUDED_)
#define __NAME_PARAM_H__INCLUDED_

#include <axis/server/AxisUserAPI.h>

/*Local name and the URI for the type*/
static const char* Axis_URI_name = "urn:uddi-org:api_v2";
static const char* Axis_TypeName_name = "name";

class name
{
public:
        name();
        ~name();
};

#endif /* !defined(__NAME_PARAM_H__INCLUDED_)*/

I have highlighed the missing parts in red for clarity.

Regards,

Fred Preston.
Software Engineer
Business Integration
Mime
View raw message