Good morning. First of all, I'm sorry for my English. I hope to be as clear as possible in describing the problem.
I have to create a client with C + + Builder 6.0 to a web service done with .Net (Visual Studio 2005).
I did everything I could find on the internet about this:
_ Created a new application;
_ File-> New-> Other-> Web Services-> WSDL importer
The WSDL Importer has created the file .h and .cpp that I use in my client.
The code off the file .h:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : // Encoding : utf-8
// Codegen : [wfDebug,wfVerbose,wfSkipHttpBindings,wfIgnoreSchemaErrors,wfSkipUnusedTypes]
// Version : 1.0
// (30/03/2009 13.46.48 - $Revision: 1.0.1.0.1.82 $)
// ************************************************************************ //
#ifndef CommonRegistryH
#define CommonRegistryH
#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <SoapHTTPClient.hpp>
namespace NS_CommonRegistry {
class TRegistryData;
enum TRegistryStatus
{
NoError,
SSRRDidNotRespond,
BadParameters
};
class TRegistryStatus_TypeInfoHolder : public TObject {
TRegistryStatus __instanceType;
public:
__published:
__property TRegistryStatus __propType = { read=__instanceType };
};
// ************************************************************************ //
// Namespace : // ************************************************************************ //
class TRegistryData : public TRemotable {
private:
AnsiString FASS_COGNOME;
AnsiString FASS_NOME;
TXSDateTime* FASS_NASC_DATA;
TXSDateTime* FDataValidazioneSSRR;
int FIDAnagrafica;
TXSDateTime* FDataValidazioneSSRRMedicoCurante;
int FIDAnagraficaMedicoCurante;
public:
__fastcall ~TRegistryData();
__published:
__property AnsiString ASS_COGNOME = { read=FASS_COGNOME, write=FASS_COGNOME };
__property AnsiString ASS_NOME = { read=FASS_NOME, write=FASS_NOME };
__property TXSDateTime* ASS_NASC_DATA = { read=FASS_NASC_DATA, write=FASS_NASC_DATA };
__property TXSDateTime* DataValidazioneSSRR = { read=FDataValidazioneSSRR, write=FDataValidazioneSSRR };
__property int IDAnagrafica = { read=FIDAnagrafica, write=FIDAnagrafica };
__property TXSDateTime* DataValidazioneSSRRMedicoCurante = { read=FDataValidazioneSSRRMedicoCurante, write=FDataValidazioneSSRRMedicoCurante };
__property int IDAnagraficaMedicoCurante = { read=FIDAnagraficaMedicoCurante, write=FIDAnagraficaMedicoCurante };
};
typedef DynamicArray<TRegistryData*> ArrayOfTRegistryData;
// ************************************************************************ //
// Namespace : // soapAction: // transport : // binding : CommonRegistrySoap
// service : CommonRegistry
// port : CommonRegistrySoap
// URL : // ************************************************************************ //
__interface INTERFACE_UUID("{06B12636-2E41-1A74-7D4F-B7D22FA2C654}") CommonRegistrySoap : public IInvokable
{
public:
virtual void SearchByCRA(const AnsiString pCRA, const bool ForceReload, const TRegistryStatus status, ArrayOfTRegistryData& SearchByCRAResult, TRegistryStatus& ResultStatus) = 0;
virtual void SearchByCF(const AnsiString pCF, const bool ForceReload, const TRegistryStatus status, ArrayOfTRegistryData& SearchByCFResult, TRegistryStatus& ResultStatus) = 0;
virtual void SearchByCNDN(const AnsiString pLastName, const AnsiString pFirstName, const TXSDateTime* pDateOfBirth, const bool ForceReload, const TRegistryStatus status, ArrayOfTRegistryData& SearchByCNDNResult, TRegistryStatus& ResultStatus) = 0;
virtual TRegistryData* InsertPaziente(const TRegistryData* pData) = 0;
};
typedef DelphiInterface<CommonRegistrySoap> _di_CommonRegistrySoap;
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL=false, AnsiString addr="");
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL=false, AnsiString addr="", THTTPRIO* HTTPRIO=NULL);
#endif // __CommonRegistry_h__
}; // NS_CommonRegistry
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace NS_CommonRegistry;
#endif
The code of file .cpp
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : // Encoding : utf-8
// Codegen : [wfDebug,wfVerbose,wfSkipHttpBindings,wfIgnoreSchemaErrors,wfSkipUnusedTypes]
// Version : 1.0
// (30/03/2009 13.46.48 - $Revision: 1.0.1.0.1.82 $)
// ************************************************************************ //
#include <vcl.h>
#pragma hdrstop
#if !defined(CommonRegistryH)
#include "CommonRegistry.h"
#endif
namespace NS_CommonRegistry {
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL, AnsiString addr)
{
static const char* defWSDL= "static const char* defURL = "static const char* defSvc = "CommonRegistry";
static const char* defPrt = "CommonRegistrySoap";
if (addr=="")
addr = useWSDL ? defWSDL : defURL;
THTTPRIO* rio = new THTTPRIO(0);
if (useWSDL) {
rio->WSDLLocation = addr;
rio->Service = defSvc;
rio->Port = defPrt;
} else {
rio->URL = addr;
}
_di_CommonRegistrySoap service;
rio->QueryInterface(service);
if (!service)
delete rio;
return service;
}
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL, AnsiString addr, THTTPRIO* HTTPRIO)
{
static const char* defWSDL= "static const char* defURL = "static const char* defSvc = "CommonRegistry";
static const char* defPrt = "CommonRegistrySoap";
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_CommonRegistrySoap service;
rio->QueryInterface(service);
if (!service && !HTTPRIO)
delete rio;
return service;
}
__fastcall TRegistryData::~TRegistryData()
{
delete FASS_NASC_DATA;
delete FDataValidazioneSSRR;
delete FDataValidazioneSSRRMedicoCurante;
}
// ************************************************************************ //
// This routine registers the interfaces and types used by invoke the SOAP
// Service.
// ************************************************************************ //
static void RegTypes()
{
/* CommonRegistrySoap */
InvRegistry()->RegisterInterface(__interfaceTypeinfo(CommonRegistrySoap), L" L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(CommonRegistrySoap), L"RemClassRegistry()->RegisterXSInfo(GetClsMemberTypeInfo(__typeinfo(TRegistryStatus_TypeInfoHolder)), L" L"TRegistryStatus");
/* TRegistryData */
RemClassRegistry()->RegisterXSClass(__classid(TRegistryData), L" L"TRegistryData");
RemClassRegistry()->RegisterXSInfo(__arrayTypeinfo(ArrayOfTRegistryData), L" L"ArrayOfTRegistryData");
}
#pragma startup RegTypes 32
}; // NS_CommonRegistry
Main Program
Following the little documentation found on the Internet, I have inserted, in the click of a button, the code for calling the web service methods.
First method:
ArrayOfTRegistryData data;
TRegistryStatus ResultStatus = NoError;
TRegistryStatus RequestStatus = NoError;
_di_CommonRegistrySoap soap = GetCommonRegistrySoap(true, "");
if (soap)
soap->SearchByCRA("ABCDEF", false, RequestStatus, data, ResultStatus);
Second method (it use a THTTPRio component added to the form):
ArrayOfTRegistryData data;
TRegistryStatus ResultStatus = NoError;
TRegistryStatus RequestStatus = NoError;
_di_CommonRegistrySoap soap = GetCommonRegistrySoap(true, "", CommonRegistryRio);
if (soap)
soap->SearchByCRA("ABCDEF", false, RequestStatus, data, ResultStatus);
Third method: it use the same THTTPRio component added in the second method with all the properties valued (in the second method, the component is passed to the function GetCommonRegistry that set the properties).
ArrayOfTRegistryData data;
TRegistryStatus ResultStatus = NoError;
TRegistryStatus RequestStatus = NoError;
_di_CommonRegistrySoap soap = NULL;
CommonRegistryRio->QueryInterface(soap);
if (soap)
{
soap->SearchByCRA("ABCDEF", false, RequestStatus, data, ResultStatus);
}
In all the methods I use, the program build correctly but when the function SearchByCRA is executed I get the error:
Unable to process request. ---> Reference to an object not set to an instance of object.
Usually I get this error when a object is not instantiated with the word new.
Then I have modified the code in main programm in this way:
ArrayOfTRegistryData *data = new ArrayOfTRegistryData();
TRegistryStatus *ResultStatus = new TRegistryStatus();
TRegistryStatus *RequestStatus = new TRegistryStatus();
*RequestStatus = NoError;
*ResultStatus = NoError;
_di_CommonRegistrySoap soap = GetCommonRegistrySoap(true, "", CommonRegistryRio);
soap->SearchByCRA("ABCDEF", false, *RequestStatus, *data, *ResultStatus);
delete [] data;
Changing the way I use to instantiate the objects, I have to change the parameter passed to the SearchByCRA (otherwise i get error from the builder). I made the same changes in all methods used.
I get the same error as before. What am I wrong? I forget something?
Thank you from now to anyone can give me a hand to solve this problem. I have already lost a day's work without resolving the problem.
I have to create a client with C + + Builder 6.0 to a web service done with .Net (Visual Studio 2005).
I did everything I could find on the internet about this:
_ Created a new application;
_ File-> New-> Other-> Web Services-> WSDL importer
The WSDL Importer has created the file .h and .cpp that I use in my client.
The code off the file .h:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : // Encoding : utf-8
// Codegen : [wfDebug,wfVerbose,wfSkipHttpBindings,wfIgnoreSchemaErrors,wfSkipUnusedTypes]
// Version : 1.0
// (30/03/2009 13.46.48 - $Revision: 1.0.1.0.1.82 $)
// ************************************************************************ //
#ifndef CommonRegistryH
#define CommonRegistryH
#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <SoapHTTPClient.hpp>
namespace NS_CommonRegistry {
class TRegistryData;
enum TRegistryStatus
{
NoError,
SSRRDidNotRespond,
BadParameters
};
class TRegistryStatus_TypeInfoHolder : public TObject {
TRegistryStatus __instanceType;
public:
__published:
__property TRegistryStatus __propType = { read=__instanceType };
};
// ************************************************************************ //
// Namespace : // ************************************************************************ //
class TRegistryData : public TRemotable {
private:
AnsiString FASS_COGNOME;
AnsiString FASS_NOME;
TXSDateTime* FASS_NASC_DATA;
TXSDateTime* FDataValidazioneSSRR;
int FIDAnagrafica;
TXSDateTime* FDataValidazioneSSRRMedicoCurante;
int FIDAnagraficaMedicoCurante;
public:
__fastcall ~TRegistryData();
__published:
__property AnsiString ASS_COGNOME = { read=FASS_COGNOME, write=FASS_COGNOME };
__property AnsiString ASS_NOME = { read=FASS_NOME, write=FASS_NOME };
__property TXSDateTime* ASS_NASC_DATA = { read=FASS_NASC_DATA, write=FASS_NASC_DATA };
__property TXSDateTime* DataValidazioneSSRR = { read=FDataValidazioneSSRR, write=FDataValidazioneSSRR };
__property int IDAnagrafica = { read=FIDAnagrafica, write=FIDAnagrafica };
__property TXSDateTime* DataValidazioneSSRRMedicoCurante = { read=FDataValidazioneSSRRMedicoCurante, write=FDataValidazioneSSRRMedicoCurante };
__property int IDAnagraficaMedicoCurante = { read=FIDAnagraficaMedicoCurante, write=FIDAnagraficaMedicoCurante };
};
typedef DynamicArray<TRegistryData*> ArrayOfTRegistryData;
// ************************************************************************ //
// Namespace : // soapAction: // transport : // binding : CommonRegistrySoap
// service : CommonRegistry
// port : CommonRegistrySoap
// URL : // ************************************************************************ //
__interface INTERFACE_UUID("{06B12636-2E41-1A74-7D4F-B7D22FA2C654}") CommonRegistrySoap : public IInvokable
{
public:
virtual void SearchByCRA(const AnsiString pCRA, const bool ForceReload, const TRegistryStatus status, ArrayOfTRegistryData& SearchByCRAResult, TRegistryStatus& ResultStatus) = 0;
virtual void SearchByCF(const AnsiString pCF, const bool ForceReload, const TRegistryStatus status, ArrayOfTRegistryData& SearchByCFResult, TRegistryStatus& ResultStatus) = 0;
virtual void SearchByCNDN(const AnsiString pLastName, const AnsiString pFirstName, const TXSDateTime* pDateOfBirth, const bool ForceReload, const TRegistryStatus status, ArrayOfTRegistryData& SearchByCNDNResult, TRegistryStatus& ResultStatus) = 0;
virtual TRegistryData* InsertPaziente(const TRegistryData* pData) = 0;
};
typedef DelphiInterface<CommonRegistrySoap> _di_CommonRegistrySoap;
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL=false, AnsiString addr="");
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL=false, AnsiString addr="", THTTPRIO* HTTPRIO=NULL);
#endif // __CommonRegistry_h__
}; // NS_CommonRegistry
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace NS_CommonRegistry;
#endif
The code of file .cpp
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : // Encoding : utf-8
// Codegen : [wfDebug,wfVerbose,wfSkipHttpBindings,wfIgnoreSchemaErrors,wfSkipUnusedTypes]
// Version : 1.0
// (30/03/2009 13.46.48 - $Revision: 1.0.1.0.1.82 $)
// ************************************************************************ //
#include <vcl.h>
#pragma hdrstop
#if !defined(CommonRegistryH)
#include "CommonRegistry.h"
#endif
namespace NS_CommonRegistry {
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL, AnsiString addr)
{
static const char* defWSDL= "static const char* defURL = "static const char* defSvc = "CommonRegistry";
static const char* defPrt = "CommonRegistrySoap";
if (addr=="")
addr = useWSDL ? defWSDL : defURL;
THTTPRIO* rio = new THTTPRIO(0);
if (useWSDL) {
rio->WSDLLocation = addr;
rio->Service = defSvc;
rio->Port = defPrt;
} else {
rio->URL = addr;
}
_di_CommonRegistrySoap service;
rio->QueryInterface(service);
if (!service)
delete rio;
return service;
}
_di_CommonRegistrySoap GetCommonRegistrySoap(bool useWSDL, AnsiString addr, THTTPRIO* HTTPRIO)
{
static const char* defWSDL= "static const char* defURL = "static const char* defSvc = "CommonRegistry";
static const char* defPrt = "CommonRegistrySoap";
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_CommonRegistrySoap service;
rio->QueryInterface(service);
if (!service && !HTTPRIO)
delete rio;
return service;
}
__fastcall TRegistryData::~TRegistryData()
{
delete FASS_NASC_DATA;
delete FDataValidazioneSSRR;
delete FDataValidazioneSSRRMedicoCurante;
}
// ************************************************************************ //
// This routine registers the interfaces and types used by invoke the SOAP
// Service.
// ************************************************************************ //
static void RegTypes()
{
/* CommonRegistrySoap */
InvRegistry()->RegisterInterface(__interfaceTypeinfo(CommonRegistrySoap), L" L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(CommonRegistrySoap), L"RemClassRegistry()->RegisterXSInfo(GetClsMemberTypeInfo(__typeinfo(TRegistryStatus_TypeInfoHolder)), L" L"TRegistryStatus");
/* TRegistryData */
RemClassRegistry()->RegisterXSClass(__classid(TRegistryData), L" L"TRegistryData");
RemClassRegistry()->RegisterXSInfo(__arrayTypeinfo(ArrayOfTRegistryData), L" L"ArrayOfTRegistryData");
}
#pragma startup RegTypes 32
}; // NS_CommonRegistry
Main Program
Following the little documentation found on the Internet, I have inserted, in the click of a button, the code for calling the web service methods.
First method:
ArrayOfTRegistryData data;
TRegistryStatus ResultStatus = NoError;
TRegistryStatus RequestStatus = NoError;
_di_CommonRegistrySoap soap = GetCommonRegistrySoap(true, "");
if (soap)
soap->SearchByCRA("ABCDEF", false, RequestStatus, data, ResultStatus);
Second method (it use a THTTPRio component added to the form):
ArrayOfTRegistryData data;
TRegistryStatus ResultStatus = NoError;
TRegistryStatus RequestStatus = NoError;
_di_CommonRegistrySoap soap = GetCommonRegistrySoap(true, "", CommonRegistryRio);
if (soap)
soap->SearchByCRA("ABCDEF", false, RequestStatus, data, ResultStatus);
Third method: it use the same THTTPRio component added in the second method with all the properties valued (in the second method, the component is passed to the function GetCommonRegistry that set the properties).
ArrayOfTRegistryData data;
TRegistryStatus ResultStatus = NoError;
TRegistryStatus RequestStatus = NoError;
_di_CommonRegistrySoap soap = NULL;
CommonRegistryRio->QueryInterface(soap);
if (soap)
{
soap->SearchByCRA("ABCDEF", false, RequestStatus, data, ResultStatus);
}
In all the methods I use, the program build correctly but when the function SearchByCRA is executed I get the error:
Unable to process request. ---> Reference to an object not set to an instance of object.
Usually I get this error when a object is not instantiated with the word new.
Then I have modified the code in main programm in this way:
ArrayOfTRegistryData *data = new ArrayOfTRegistryData();
TRegistryStatus *ResultStatus = new TRegistryStatus();
TRegistryStatus *RequestStatus = new TRegistryStatus();
*RequestStatus = NoError;
*ResultStatus = NoError;
_di_CommonRegistrySoap soap = GetCommonRegistrySoap(true, "", CommonRegistryRio);
soap->SearchByCRA("ABCDEF", false, *RequestStatus, *data, *ResultStatus);
delete [] data;
Changing the way I use to instantiate the objects, I have to change the parameter passed to the SearchByCRA (otherwise i get error from the builder). I made the same changes in all methods used.
I get the same error as before. What am I wrong? I forget something?
Thank you from now to anyone can give me a hand to solve this problem. I have already lost a day's work without resolving the problem.