由WSDL文件生成的C++builder程序见以下:
//—-主文件CorpEntityService.cpp—
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : G:\web\wsdl\CorpEntityService.wsdl
// Encoding : UTF-8
// Version : 1.0
// (2007-3-28 21:09:17 – $Revision: 1.0.1.0.1.82 $)
// ************************************************************************ //#include
#pragma hdrstop
#if !defined(CorpEntityServiceH)
#include “CorpEntityService.h”
#endif
namespace NS_CorpEntityService {
_di_CorpEntityEndpoint GetCorpEntityEndpoint(bool useWSDL, AnsiString addr)
{
static const char* defWSDL= “G:\web\wsdl\CorpEntityService.wsdl”;
static const char* defURL = “http://220.165.93.74:8080/ncms/services/CorpEntityService”;
static const char* defSvc = “CorpEntityEndpointService”;
static const char* defPrt = “CorpEntityService”;
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_CorpEntityEndpoint service;
rio->QueryInterface(service);
if (!service)
delete rio;
return service;
}
__fastcall CorpEntityWSResultDTO::~CorpEntityWSResultDTO()
{
delete FdateOfBirth;
}
// ************************************************************************ //
// This routine registers the interfaces and types used by invoke the SOAP
// Service.
// ************************************************************************ //
static void RegTypes()
{
/* CorpEntityEndpoint */
InvRegistry()->RegisterInterface(__interfaceTypeinfo(CorpEntityEndpoint), L”http://com.bdcc.ncms.webservice.corpentity.CorpEntityService”, L”UTF-8″);
InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(CorpEntityEndpoint), L”");
/* User */
RemClassRegistry()->RegisterXSClass(__classid(User), L”http://security.webservice.ncms.bdcc.com”, L”User”);
/* CorpEntityWSParamDTO */
RemClassRegistry()->RegisterXSClass(__classid(CorpEntityWSParamDTO), L”http://dto.corpentity.ncms.bdcc.com”, L”CorpEntityWSParamDTO”);
/* CorpEntityWSResultDTO */
RemClassRegistry()->RegisterXSClass(__classid(CorpEntityWSResultDTO), L”http://dto.corpentity.ncms.bdcc.com”, L”CorpEntityWSResultDTO”);
}
#pragma startup RegTypes 32
}; // NS_CorpEntityService
///////////————CorpEntityService.h文件——–
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : G:\web\wsdl\CorpEntityService.wsdl
// Encoding : UTF-8
// Version : 1.0
// (2007-3-28 21:09:17 – $Revision: 1.0.1.0.1.82 $)
// ************************************************************************ //
#ifndef CorpEntityServiceH
#define CorpEntityServiceH
#include
#include
#include
#include
namespace NS_CorpEntityService {
// ************************************************************************ //
// 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://schemas.xmlsoap.org/soap/encoding/”
// !:long – “http://schemas.xmlsoap.org/soap/encoding/”
// !:NcmsBaseDTO – “http://dto.corpentity.ncms.bdcc.com”
// !:dateTime – “http://www.w3.org/2001/XMLSchema”
class User;
class CorpEntityWSParamDTO;
class CorpEntityWSResultDTO;
// ************************************************************************ //
// Namespace : http://security.webservice.ncms.bdcc.com
// ************************************************************************ //
class User : public TRemotable {
private:
AnsiString Fpassword;
AnsiString FuserName;
public:
__published:
__property AnsiString password = { read=Fpassword, write=Fpassword };
__property AnsiString userName = { read=FuserName, write=FuserName };
};
// ************************************************************************ //
// Namespace : http://dto.corpentity.ncms.bdcc.com
// ************************************************************************ //
class CorpEntityWSParamDTO : public TRemotable {
private:
AnsiString FcardNo;
__int64 FpersonCode;
AnsiString FpersonName;
public:
__published:
__property AnsiString cardNo = { read=FcardNo, write=FcardNo };
__property __int64 personCode = { read=FpersonCode, write=FpersonCode };
__property AnsiString personName = { read=FpersonName, write=FpersonName };
};
// ************************************************************************ //
// Namespace : http://dto.corpentity.ncms.bdcc.com
// ************************************************************************ //
class CorpEntityWSResultDTO : public TRemotable {
private:
AnsiString Faddress;
AnsiString FcardNo;
TXSDateTime* FdateOfBirth;
AnsiString FerrorCode;
AnsiString Fidentification;
AnsiString FisActive;
__int64 FpersonCode;
__int64 FpersonId;
AnsiString FpersonName;
AnsiString Fsex;
AnsiString Fstatus;
public:
__fastcall ~CorpEntityWSResultDTO();
__published:
__property AnsiString address = { read=Faddress, write=Faddress };
__property AnsiString cardNo = { read=FcardNo, write=FcardNo };
__property TXSDateTime* dateOfBirth = { read=FdateOfBirth, write=FdateOfBirth };
__property AnsiString errorCode = { read=FerrorCode, write=FerrorCode };
__property AnsiString identification = { read=Fidentification, write=Fidentification };
__property AnsiString isActive = { read=FisActive, write=FisActive };
__property __int64 personCode = { read=FpersonCode, write=FpersonCode };
__property __int64 personId = { read=FpersonId, write=FpersonId };
__property AnsiString personName = { read=FpersonName, write=FpersonName };
__property AnsiString sex = { read=Fsex, write=Fsex };
__property AnsiString status = { read=Fstatus, write=Fstatus };
};
// ************************************************************************ //
// Namespace : http://com.bdcc.ncms.webservice.corpentity.CorpEntityService
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : CorpEntityServiceSoapBinding
// service : CorpEntityEndpointService
// port : CorpEntityService
// URL : http://localhost:8080/ncms/services/CorpEntityService
// ************************************************************************ //
__interface INTERFACE_UUID(“{E9115789-3B20-0C6B-37C5-35E5B5BE203D}”) CorpEntityEndpoint : public IInvokable
{
public:
virtual CorpEntityWSResultDTO* getCorpEntity(const User* user, const CorpEntityWSParamDTO* dto) = 0;
};
typedef DelphiInterface _di_CorpEntityEndpoint;
_di_CorpEntityEndpoint GetCorpEntityEndpoint(bool useWSDL=false, AnsiString addr=”");
#endif // __CorpEntityService_h__
}; // NS_CorpEntityService
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace NS_CorpEntityService;
#endif
谁能讲解一下。我该怎么调用里边的方法。该用什么控件。怎么调用。谢谢。
看了这个C++builder根据WSDL导入生成的接口文件,知道是怎么回事了,就是要做一个SOAP/Web Service的程序。看了这个熟悉的C++ Builder代码,又再看了一下接口的说明,发现文档编写的几个疏忽:
接口文档只说明了输入输出参数,但是com.bdc.ncms.corpentity.dto. CorpEntityWsparamDTO的写法并不适合接口文档。
SOAP(Simple Object Access Protocol) 是一个标准,目前的很多Web Service 都使用这个来交换数据,目前都是使用http/https。Delphi在开发SOAP程序有多种选择,灵活性非常高,做一个简单的Web Service 程序也就是几分钟的事情。