Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem Deserializing Array Of Objects

32 views
Skip to first unread message

Jair Karim Tinoco

unread,
May 3, 2007, 9:52:36 PM5/3/07
to
Hi,
I have a web service that returns an array of objects, response XML is like
the next:

Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0
date=200610162339)/Tomcat-5.5
Set-Cookie: JSESSIONID=BFB5459D61DC197FBBC4DF43CF9FA080; Path=/
Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Fri, 04 May 2007 00:11:12 GMT

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header/>
<env:Body>
<ns1:encuentraPaisesResponse xmlns:ns1='http://model.siiu.com/jaws'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<ns1:result>
<ns1:abrev xmlns:ns1='http://model.siiu.com/jaws'>MEX</ns1:abrev>
<ns1:idpais xmlns:ns1='http://model.siiu.com/jaws'>MX</ns1:idpais>
<ns1:nombre xmlns:ns1='http://model.siiu.com/jaws'>MEXICO</ns1:nombre>
</ns1:result>
<ns1:result>
<ns1:abrev xmlns:ns1='http://model.siiu.com/jaws'>USA</ns1:abrev>
<ns1:idpais xmlns:ns1='http://model.siiu.com/jaws'>US</ns1:idpais>
<ns1:nombre xmlns:ns1='http://model.siiu.com/jaws'>ESTADOS
UNIDOS</ns1:nombre>
</ns1:result>
</ns1:encuentraPaisesResponse>
</env:Body>
</env:Envelope>

SOAP runtime in Delphi works perfectly but in C++ doesn't, as you can see my
web service is DOCUMENT/LITERAL style, i'm using fixed SOAP Runtime from
Pascal Units provided from Bruneau Babet, i'mm working with BDS2006.

The generated files by wsdlimp.exe for C++ are:

PaisFacade.cpp

// ************************************************************************
//
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:8080/SiiuEJBModule/PaisFacade?wsdl
// >Import : http://localhost:8080/SiiuEJBModule/PaisFacade?wsdl:0
// >Import : http://localhost:8080/SiiuEJBModule/PaisFacade?wsdl:1
// (03/05/2007 08:36:07 p.m. - - $Rev: 5569 $)
// ************************************************************************
//

#include <vcl.h>
#pragma hdrstop

#if !defined(PaisFacadeH)
#include "PaisFacade.h"
#endif

namespace NS_PaisFacade {

_di_PaisFacade GetPaisFacade(bool useWSDL, AnsiString addr, THTTPRIO*
HTTPRIO)
{
static const char* defWSDL=
"http://localhost:8080/SiiuEJBModule/PaisFacade?wsdl";
static const char* defURL =
"http://Contabilidad:8080/SiiuEJBModule/PaisFacade";
static const char* defSvc = "PaisFacadeService";
static const char* defPrt = "PaisFacadePort";
if (addr=="")
addr = useWSDL ? defWSDL : defURL;
THTTPRIO* rio = HTTPRIO ? HTTPRIO : new THTTPRIO(0);
if (useWSDL) {
rio->WSDLLocation = addr;
rio->Service = defSvc;
rio->Port = defPrt;
} else {
rio->URL = addr;
}
_di_PaisFacade service;
rio->QueryInterface(service);
if (!service && !HTTPRIO)
delete rio;
return service;
}


// ************************************************************************
//
// This routine registers the interfaces and types used by invoke the SOAP
// Service.
// ************************************************************************
//
static void RegTypes()
{
/* PaisFacade */
InvRegistry()->RegisterInterface(__interfaceTypeinfo(PaisFacade),
L"http://facade.siiu.com/jaws", L"");
InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(PaisFacade),
L"");
InvRegistry()->RegisterInvokeOptions(__interfaceTypeinfo(PaisFacade),
ioDocument);
/* Pais */
RemClassRegistry()->RegisterXSClass(__classid(Pais),
L"http://model.siiu.com/jaws", L"Pais");
RemClassRegistry()->RegisterXSInfo(__arrayTypeinfo(Array_Of_Pais),
L"http://model.siiu.com/jaws", L"Array_Of_Pais");
}
#pragma startup RegTypes 32

}; // NS_PaisFacade

And PaisFacade.h

// ************************************************************************
//
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:8080/SiiuEJBModule/PaisFacade?wsdl
// >Import : http://localhost:8080/SiiuEJBModule/PaisFacade?wsdl:0
// >Import : http://localhost:8080/SiiuEJBModule/PaisFacade?wsdl:1
// (03/05/2007 08:36:07 p.m. - - $Rev: 5569 $)
// ************************************************************************
//

#ifndef PaisFacadeH
#define PaisFacadeH

#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <SOAPHTTPClient.hpp>

#if !defined(SOAP_REMOTABLE_CLASS)
#define SOAP_REMOTABLE_CLASS __declspec(delphiclass)
#endif
#if !defined(AS_UNBOUNDED)
#define AS_UNBOUNDED false
#endif
#if !defined(AS_ATTRIBUTE)
#define AS_ATTRIBUTE false
#endif


namespace NS_PaisFacade {

// ************************************************************************
//
// The following types, referred to in the WSDL document are not being
represented
// in this file. They are either aliases[@] of other types represented or
were referred
// to but never[!] declared in the document. The types from the latter
category
// typically map to predefined/known XML or Borland types; however, they
could also
// indicate incorrect WSDL documents that failed to declare or import a
schema type.
// ************************************************************************
//
// !:string - "http://www.w3.org/2001/XMLSchema"

class SOAP_REMOTABLE_CLASS Pais;

// ************************************************************************
//
// XML : Pais, global, <complexType>
// Namespace : http://model.siiu.com/jaws
// ************************************************************************
//
class Pais : public TRemotable {
private:
WideString Fabrev;
WideString Fidpais;
WideString Fnombre;
public:
__published:
__property WideString abrev = { read=Fabrev, write=Fabrev };
__property WideString idpais = { read=Fidpais, write=Fidpais };
__property WideString nombre = { read=Fnombre, write=Fnombre };
};


typedef DynamicArray<Pais*> Array_Of_Pais; /*
"http://model.siiu.com/jaws"[Gblunbnd] */

// ************************************************************************
//
// Namespace : http://facade.siiu.com/jaws
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : PaisFacadeBinding
// service : PaisFacadeService
// port : PaisFacadePort
// URL : http://Contabilidad:8080/SiiuEJBModule/PaisFacade
// ************************************************************************
//
__interface INTERFACE_UUID("{02E77375-C84D-5824-603C-964313FAE390}")
PaisFacade : public IInvokable
{
public:
virtual void actualizaPais(const Pais* Pais_1) = 0;
virtual void borraPais(const Pais* Pais_1) = 0;
virtual void creaPais(const Pais* Pais_1) = 0;
virtual Pais* encuentraPais(const WideString String_1) = 0;
virtual Array_Of_Pais encuentraPaises() = 0;
};
typedef DelphiInterface<PaisFacade> _di_PaisFacade;

_di_PaisFacade GetPaisFacade(bool useWSDL=false, AnsiString addr="",
THTTPRIO* HTTPRIO=0);


}; // NS_PaisFacade

#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace NS_PaisFacade;
#endif

#endif // PaisFacadeH


Works the same Delphi runtime for C++ application? or i need other SOAP
runtime for C++.
Somebody have any idea?

Thanks in advance!!

Jair Karim

Jean-Marie Babet

unread,
May 4, 2007, 5:12:01 PM5/4/07
to
Hello Jair,

First of all my apologies: I saw your earlier post and had good intentions
to follow up but then work did what it's doing so well lately:(

What version of the importer are you using? I see it $Rev:5569. I don't know
if the unbounded support had been ported to the C++ writer yet [the reader
portion is shared between Delphi and C++]. The best approach would be:

#1 Either I send you the latest importer - which definitely includes the
same level of support as Delphi's

#2 Or you send me the WSDL so I may investigate.

Let me know!

Cheers,

Bruneau.


Jair Karim Tinoco

unread,
May 4, 2007, 8:46:03 PM5/4/07
to
Hi Bruneau,
Don't worry for the elapsed time of your response, almost people in this
world are busy.

WSDL for this test is the next:

<definitions name='PaisFacadeService'
targetNamespace='http://facade.siiu.com/jaws'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:ns1='http://model.siiu.com/jaws'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://facade.siiu.com/jaws'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<types>
<schema elementFormDefault='qualified'
targetNamespace='http://model.siiu.com/jaws'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:ns1='http://facade.siiu.com/jaws'
xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:tns='http://model.siiu.com/jaws'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<import namespace='http://facade.siiu.com/jaws'/>
<complexType name='Pais'>
<sequence>
<element name='abrev' nillable='true' type='string'/>
<element name='idpais' nillable='true' type='string'/>
<element name='nombre' nillable='true' type='string'/>
</sequence>
</complexType>
</schema>
<schema elementFormDefault='qualified'
targetNamespace='http://facade.siiu.com/jaws'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:ns2='http://model.siiu.com/jaws'
xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:tns='http://facade.siiu.com/jaws'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<import namespace='http://model.siiu.com/jaws'/>
<complexType name='actualizaPais'>
<sequence>
<element name='Pais_1' nillable='true' type='ns2:Pais'/>
</sequence>
</complexType>
<complexType name='actualizaPaisResponse'>
<sequence/>
</complexType>
<complexType name='borraPais'>
<sequence>
<element name='Pais_1' nillable='true' type='ns2:Pais'/>
</sequence>
</complexType>
<complexType name='borraPaisResponse'>
<sequence/>
</complexType>
<complexType name='creaPais'>
<sequence>
<element name='Pais_1' nillable='true' type='ns2:Pais'/>
</sequence>
</complexType>
<complexType name='creaPaisResponse'>
<sequence/>
</complexType>
<complexType name='encuentraPais'>
<sequence>
<element name='String_1' nillable='true' type='string'/>
</sequence>
</complexType>
<complexType name='encuentraPaisResponse'>
<sequence>
<element name='result' nillable='true' type='ns2:Pais'/>
</sequence>
</complexType>
<complexType name='encuentraPaises'>
<sequence/>
</complexType>
<complexType name='encuentraPaisesResponse'>
<sequence>
<element maxOccurs='unbounded' minOccurs='0' name='result'
nillable='true' type='ns2:Pais'/>
</sequence>
</complexType>
<element name='actualizaPais' type='tns:actualizaPais'/>
<element name='actualizaPaisResponse' type='tns:actualizaPaisResponse'/>
<element name='borraPais' type='tns:borraPais'/>
<element name='borraPaisResponse' type='tns:borraPaisResponse'/>
<element name='creaPais' type='tns:creaPais'/>
<element name='creaPaisResponse' type='tns:creaPaisResponse'/>
<element name='encuentraPais' type='tns:encuentraPais'/>
<element name='encuentraPaisResponse' type='tns:encuentraPaisResponse'/>
<element name='encuentraPaises' type='tns:encuentraPaises'/>
<element name='encuentraPaisesResponse'
type='tns:encuentraPaisesResponse'/>
</schema>
</types>
<message name='PaisFacade_borraPaisResponse'>
<part element='tns:borraPaisResponse' name='result'/>
</message>
<message name='PaisFacade_actualizaPaisResponse'>
<part element='tns:actualizaPaisResponse' name='result'/>
</message>
<message name='PaisFacade_actualizaPais'>
<part element='tns:actualizaPais' name='parameters'/>
</message>
<message name='PaisFacade_encuentraPaisesResponse'>
<part element='tns:encuentraPaisesResponse' name='result'/>
</message>
<message name='PaisFacade_encuentraPaises'>
<part element='tns:encuentraPaises' name='parameters'/>
</message>
<message name='PaisFacade_encuentraPais'>
<part element='tns:encuentraPais' name='parameters'/>
</message>
<message name='PaisFacade_creaPais'>
<part element='tns:creaPais' name='parameters'/>
</message>
<message name='PaisFacade_borraPais'>
<part element='tns:borraPais' name='parameters'/>
</message>
<message name='PaisFacade_encuentraPaisResponse'>
<part element='tns:encuentraPaisResponse' name='result'/>
</message>
<message name='PaisFacade_creaPaisResponse'>
<part element='tns:creaPaisResponse' name='result'/>
</message>
<portType name='PaisFacade'>
<operation name='actualizaPais'>
<input message='tns:PaisFacade_actualizaPais'/>
<output message='tns:PaisFacade_actualizaPaisResponse'/>
</operation>
<operation name='borraPais'>
<input message='tns:PaisFacade_borraPais'/>
<output message='tns:PaisFacade_borraPaisResponse'/>
</operation>
<operation name='creaPais'>
<input message='tns:PaisFacade_creaPais'/>
<output message='tns:PaisFacade_creaPaisResponse'/>
</operation>
<operation name='encuentraPais'>
<input message='tns:PaisFacade_encuentraPais'/>
<output message='tns:PaisFacade_encuentraPaisResponse'/>
</operation>
<operation name='encuentraPaises'>
<input message='tns:PaisFacade_encuentraPaises'/>
<output message='tns:PaisFacade_encuentraPaisesResponse'/>
</operation>
</portType>
<binding name='PaisFacadeBinding' type='tns:PaisFacade'>
<soap:binding style='document'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='actualizaPais'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal'/>
</input>
<output>
<soap:body use='literal'/>
</output>
</operation>
<operation name='borraPais'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal'/>
</input>
<output>
<soap:body use='literal'/>
</output>
</operation>
<operation name='creaPais'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal'/>
</input>
<output>
<soap:body use='literal'/>
</output>
</operation>
<operation name='encuentraPais'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal'/>
</input>
<output>
<soap:body use='literal'/>
</output>
</operation>
<operation name='encuentraPaises'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal'/>
</input>
<output>
<soap:body use='literal'/>
</output>
</operation>
</binding>
<service name='PaisFacadeService'>
<port binding='tns:PaisFacadeBinding' name='PaisFacadePort'>
<soap:address
location='http://Contabilidad:8080/SiiuEJBModule/PaisFacade'/>
</port>
</service>
</definitions>

As you can see, style is DOCUMENT/LITERAL, parameter pass works fine and
array objects deserializing fails, however with RPC/LITERAL style an array
of objects deserializing works fine, but parameter pass to web services
fails.

I'm using wsdl importer rev $5569, some weeks ago you send me an fixed wsdl
importer rev $3108, the last importer was downloaded from codegear web site
in the next URL:

http://codecentral.codegear.com/Item/24535

Functional behavior is inverted when i use one style or another. The web
service is an EJB 3.0 exposed through JBossWS with JSR-181 specification,
JSR-181 doesn't support RPC/ENCODED so i can't use this style.

If a newer SOAP runtime and wsdl importer exists please send it to me.

Jean-Marie Babet

unread,
May 10, 2007, 8:32:13 PM5/10/07
to
Hello,

Squeezing a few minutes to catch up on the newsgroup.

I imported the WSDL posted with the latest importer and it generated the
following (pasted below). I'm not sure if this matches what you have. If
not, I can email you what I have. Please let me know.

Cheers,

Bruneau.

[[[[[HEADER]]]]]

// ************************************************************************
//
// The types declared in this file were generated from data read from the
// WSDL File described below:

// WSDL : test.wsdl
// >Import : test.wsdl:0
// >Import : test.wsdl:1
// (5/10/2007 5:26:18 PM - - $Rev: 6632 $)
// ************************************************************************
//

#ifndef testH
#define testH

#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <SOAPHTTPClient.hpp>

#if !defined(SOAP_REMOTABLE_CLASS)
#define SOAP_REMOTABLE_CLASS __declspec(delphiclass)
#endif

#if !defined(IS_OPTN)
#define IS_OPTN 0x0001
#endif
#if !defined(IS_UNBD)
#define IS_UNBD 0x0002
#endif
#if !defined(IS_NLBL)
#define IS_NLBL 0x0004
#endif


namespace NS_test {

class SOAP_REMOTABLE_CLASS Pais;

__published:
__property WideString abrev = { index=(IS_NLBL), read=Fabrev,
write=Fabrev };
__property WideString idpais = { index=(IS_NLBL), read=Fidpais,
write=Fidpais };
__property WideString nombre = { index=(IS_NLBL), read=Fnombre,
write=Fnombre };
};


typedef DynamicArray<Pais*> Array_Of_Pais; /*

"http://model.siiu.com/jaws"[GblUbnd] */

// ************************************************************************
//
// Namespace : http://facade.siiu.com/jaws
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : PaisFacadeBinding
// service : PaisFacadeService
// port : PaisFacadePort
// URL : http://Contabilidad:8080/SiiuEJBModule/PaisFacade
// ************************************************************************
//
__interface INTERFACE_UUID("{02E77375-C84D-5824-603C-964313FAE390}")
PaisFacade : public IInvokable
{
public:
virtual void actualizaPais(const Pais* Pais_1) = 0;
virtual void borraPais(const Pais* Pais_1) = 0;
virtual void creaPais(const Pais* Pais_1) = 0;
virtual Pais* encuentraPais(const WideString String_1) = 0;
virtual Array_Of_Pais encuentraPaises() = 0;
};
typedef DelphiInterface<PaisFacade> _di_PaisFacade;

_di_PaisFacade GetPaisFacade(bool useWSDL=false, AnsiString addr="",
THTTPRIO* HTTPRIO=0);


}; // NS_test

#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace NS_test;
#endif

#endif // testH


[[[[[SOURCE]]]]]

// ************************************************************************
//
// The types declared in this file were generated from data read from the
// WSDL File described below:

// WSDL : test.wsdl
// >Import : test.wsdl:0
// >Import : test.wsdl:1
// (5/10/2007 5:26:18 PM - - $Rev: 6632 $)
// ************************************************************************
//

#include <vcl.h>
#pragma hdrstop

#if !defined(testH)
#include "test.h"
#endif

namespace NS_test {

_di_PaisFacade GetPaisFacade(bool useWSDL, AnsiString addr, THTTPRIO*
HTTPRIO)
{

static const char* defWSDL= "test.wsdl";


static const char* defURL =
"http://Contabilidad:8080/SiiuEJBModule/PaisFacade";
static const char* defSvc = "PaisFacadeService";
static const char* defPrt = "PaisFacadePort";
if (addr=="")
addr = useWSDL ? defWSDL : defURL;
THTTPRIO* rio = HTTPRIO ? HTTPRIO : new THTTPRIO(0);
if (useWSDL) {
rio->WSDLLocation = addr;
rio->Service = defSvc;
rio->Port = defPrt;
} else {
rio->URL = addr;
}
_di_PaisFacade service;
rio->QueryInterface(service);
if (!service && !HTTPRIO)
delete rio;
return service;
}


// ************************************************************************
//
// This routine registers the interfaces and types exposed by the
WebService.


// ************************************************************************
//
static void RegTypes()
{
/* PaisFacade */
InvRegistry()->RegisterInterface(__interfaceTypeinfo(PaisFacade),
L"http://facade.siiu.com/jaws", L"");
InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(PaisFacade),
L"");
InvRegistry()->RegisterInvokeOptions(__interfaceTypeinfo(PaisFacade),
ioDocument);
/* Pais */
RemClassRegistry()->RegisterXSClass(__classid(Pais),
L"http://model.siiu.com/jaws", L"Pais");

/* Array_Of_Pais */


RemClassRegistry()->RegisterXSInfo(__arrayTypeinfo(Array_Of_Pais),
L"http://model.siiu.com/jaws", L"Array_Of_Pais");
}
#pragma startup RegTypes 32

}; // NS_test


Jair Karim Tinoco

unread,
May 11, 2007, 11:40:32 AM5/11/07
to
Hi,
generated code you sent me matchs with my generated code, so WSDL Importer
is not the cause, i did tests with Delphi BDS 2006 and everything works fine
when last SOAP runtime is used, when original SOAP runtime from factory is
used the behavior is the same that in C++ Builder BDS 2006, array of objects
deserializaing doesn't work.

So, i think we don't use correctly the fixed SOAP runtime in C++ because at
compile time still requires original from factory LIB files (soaprtl.lib).

How can i substitute the original SOAP runtime with the fixed SOAP runtime
for use in C++ BS 2006?

Jean-Marie Babet

unread,
May 11, 2007, 2:27:49 PM5/11/07
to
Hello Jair,

It's a little harder to use the new runtime with C++. With Delphi all you
have to do is ensure that the runtime is on the search path before the
standard Units we ship. With C++ one has two options:

1. Add the updated .pas runtime directly to the project. (The IDE will
compile then, generating new .obj files, and link with the latter).

2. Rebuild the soaprtl.lib library.

Option #2 can be a little complicated as earlier versions of DCC32 did not
automatically generate the .lib file: you had to build the .obj/.hpp files
and then run TLIB on the .obj files to create the library.

What version of C++ will you be using to build the C++ app? I'll try to put
something together that creates the library.

Cheers,

Bruneau.


Jair Karim Tinoco

unread,
May 28, 2007, 7:39:46 PM5/28/07
to
Hello Bruneau,
I'm using C++ Borland Developer Studio 2006 Enterprise Edition Update 2.

Thanks!!

Jair Karim

0 new messages