Aslında ilk önce tarif ettiğiniz yere bakmıştım yukarıda belirttiğim gibi. Client tarafını bir şekilde c++ a çevirdim fakat servis tarafını çeviremedim.
Service:
.cpp
Kod: Tümünü seç
// ************************************************************************ //
// Implementation class for interface Iaaasdf
// ************************************************************************ //
#include <stdio.h>
#include <vcl.h>
#pragma hdrstop
#if !defined(__aaasdf_h__)
#include "aaasdf.h"
#endif
// ************************************************************************ //
// TaaasdfImpl implements interface Iaaasdf
// ************************************************************************ //
class TaaasdfImpl : public TInvokableClass, public Iaaasdf {
public:
/* Sample methods of Iaaasdf */
SampleEnum echoEnum(SampleEnum eValue);
TDoubleArray echoDoubleArray(const TDoubleArray daValue);
TSampleStruct* echoStruct(const TSampleStruct* pStruct);
double echoDouble(double dValue);
/* IUnknown */
HRESULT STDMETHODCALLTYPE QueryInterface(const GUID& IID, void **Obj) {
return GetInterface(IID, Obj) ? S_OK : E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef() {
return TInvokableClass::_AddRef();
}
ULONG STDMETHODCALLTYPE Release() {
return TInvokableClass::_Release();
}
bool CheckHeader(){
// ??
return true;
}
};
SampleEnum TaaasdfImpl::echoEnum(SampleEnum eValue) {
/* TODO : Implement method echoEnum */
return eValue;
}
TDoubleArray TaaasdfImpl::echoDoubleArray(TDoubleArray daValue) {
/* TODO : Implement method echoDoubleArray */
return daValue;
}
TSampleStruct* TaaasdfImpl::echoStruct(const TSampleStruct* pEmployee) {
/* TODO : Implement method echoMyEmployee */
return new TSampleStruct();
}
double TaaasdfImpl::echoDouble(const double dValue) {
/* TODO : Implement method echoDouble */
return dValue;
}
static void __fastcall aaasdfFactory(System::TObject* &obj) {
static _di_Iaaasdf iInstance;
static TaaasdfImpl *instance = 0;
if (!instance) {
instance = new TaaasdfImpl();
instance->GetInterface(iInstance);
}
obj = instance;
if(!instance->CheckHeader()){
// ??
}
}
// ************************************************************************ //
// The following routine registers the interface and implementation class
// as well as the type used by the methods of the interface
// ************************************************************************ //
static void RegTypes() {
InvRegistry()->RegisterInterface(__delphirtti(Iaaasdf));
InvRegistry()->RegisterInvokableClass(__classid(TaaasdfImpl), aaasdfFactory);
InvRegistry()->RegisterHeaderClass(__delphirtti(Iaaasdf), __classid(MySOAPHeader));
}
#pragma startup RegTypes 32
.h
Kod: Tümünü seç
// ************************************************************************ //
// Invokable interface declaration header for aaasdf
// ************************************************************************ //
#ifndef aaasdfH
#define aaasdfH
#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <Types.hpp>
// ************************************************************************ //
// Enums exposed via SOAP must be byte-aligned
// ************************************************************************ //
#pragma option -b-
enum SampleEnum {
etNone, etAFew, etSome, etALot
};
#pragma option -b.
// ************************************************************************ //
// To expose complex types via SOAP, the type must derive from TRemotable
// All published members of the type will be exposed.
// ************************************************************************ //
class TSampleStruct : public TRemotable {
private:
AnsiString FLastName;
AnsiString FFirstName;
double FSalary;
__published:
__property AnsiString LastName = {read = FLastName, write = FLastName};
__property AnsiString FirstName = {read = FFirstName, write = FFirstName};
__property double Salary = {read = FSalary, write = FSalary};
};
class MySOAPHeader : public TSOAPHeader {
private:
UnicodeString FUsername;
UnicodeString FPassword;
__published:
__property UnicodeString Username = {read = FUsername, write = FUsername};
__property UnicodeString Password = {read = FPassword, write = FPassword};
};
// ************************************************************************ //
// Remotable arrays must be Dynamic arrays since they must be discoverable
// at runtime.
// ************************************************************************ //
typedef DynamicArray<double>TDoubleArray;
// ************************************************************************ //
// Invokable interfaces must derive from IInvokable
// The methods of the interface will be exposed via SOAP
// ************************************************************************ //
__interface INTERFACE_UUID("{6D3639F4-DEB4-41D6-8E09-B3623B8232CA}") Iaaasdf : public IInvokable {
public:
virtual SampleEnum echoEnum(SampleEnum eValue) = 0;
virtual TDoubleArray echoDoubleArray(const TDoubleArray daValue) = 0;
virtual TSampleStruct* echoStruct(const TSampleStruct* pEmployee) = 0;
virtual double echoDouble(double dValue) = 0;
};
typedef DelphiInterface<Iaaasdf>_di_Iaaasdf;
#endif // aaasdfH
// ---------------------------------------------------------------------------
Client tarafında bir problemim yok diye düşünüyorum. Servise gönderdiğim SOAP mesajını loglayıp kontrol ettim, hatta önceki mesajımda paylaşmıştım SOAP Envelop'u. Yine de client kodunu aşağıda paylaşıyorum.
Client:
.cpp
Kod: Tümünü seç
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl
// >Import : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl>0
// >Import : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl>1
// >Import : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl>2
// Version : 1.0
// (25.10.2017 20:28:26 - - $Rev: 56641 $)
// ************************************************************************ //
#include <System.hpp>
#pragma hdrstop
#if !defined(IaaasdfH)
#include "Iaaasdf.h"
#endif
namespace NS_Iaaasdf {
_di_Iaaasdf GetIaaasdf(bool useWSDL, System::String addr, Soaphttpclient::THTTPRIO* HTTPRIO)
{
static const char* defWSDL= "D:\\PROJELER\\MyC++\\trainer\\65 ws client auth\\Iaaasdf.wsdl";
static const char* defURL = "http://localhost:8080/soap/Iaaasdf";
static const char* defSvc = "Iaaasdfservice";
static const char* defPrt = "IaaasdfPort";
if (addr=="")
addr = useWSDL ? defWSDL : defURL;
Soaphttpclient::THTTPRIO* rio = HTTPRIO ? HTTPRIO : new Soaphttpclient::THTTPRIO(0);
if (useWSDL) {
rio->WSDLLocation = addr;
rio->Service = defSvc;
rio->Port = defPrt;
MySOAPHeader *hdr = new MySOAPHeader();
hdr->Username = "deneme";
hdr->Password = "test123";
rio->SOAPHeaders->Send(hdr);
} else {
rio->URL = addr;
}
_di_Iaaasdf 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()
{
/* Iaaasdf */
InvRegistry()->RegisterInterface(__delphirtti(Iaaasdf), L"urn:aaasdf-Iaaasdf", L"");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(Iaaasdf), L"urn:aaasdf-Iaaasdf#%operationName%");
/* Iaaasdf->echoEnum */
InvRegistry()->RegisterParamInfo(__delphirtti(Iaaasdf), "echoEnum", "return_", L"return", L"");
/* Iaaasdf->echoDoubleArray */
InvRegistry()->RegisterParamInfo(__delphirtti(Iaaasdf), "echoDoubleArray", "return_", L"return", L"");
/* Iaaasdf->echoStruct */
InvRegistry()->RegisterParamInfo(__delphirtti(Iaaasdf), "echoStruct", "return_", L"return", L"");
/* Iaaasdf->echoDouble */
InvRegistry()->RegisterParamInfo(__delphirtti(Iaaasdf), "echoDouble", "return_", L"return", L"");
/* MySOAPHeader */
RemClassRegistry()->RegisterXSClass(__classid(MySOAPHeader), L"urn:@:aaasdf", L"MySOAPHeader");
/* SampleEnum */
RemClassRegistry()->RegisterXSInfo(GetClsMemberTypeInfo(__typeinfo(SampleEnum_TypeInfoHolder)), L"urn:aaasdf", L"SampleEnum");
/* TSampleStruct */
RemClassRegistry()->RegisterXSClass(__classid(TSampleStruct), L"urn:@:aaasdf", L"TSampleStruct");
}
#pragma startup RegTypes 32
}; // NS_Iaaasdf
.h
Kod: Tümünü seç
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl
// >Import : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl>0
// >Import : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl>1
// >Import : D:\PROJELER\MyC++\trainer\65 ws client auth\Iaaasdf.wsdl>2
// Version : 1.0
// (25.10.2017 20:28:26 - - $Rev: 56641 $)
// ************************************************************************ //
#ifndef IaaasdfH
#define IaaasdfH
#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <SOAPHTTPClient.hpp>
#if !defined(SOAP_REMOTABLE_CLASS)
#define SOAP_REMOTABLE_CLASS __declspec(delphiclass)
#endif
namespace NS_Iaaasdf {
// ************************************************************************ //
// 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 Embarcadero 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"[Gbl]
// !:double - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:TDoubleDynArray - "http://www.borland.com/namespaces/Types"[GblCplx]
class SOAP_REMOTABLE_CLASS MySOAPHeader;
class SOAP_REMOTABLE_CLASS TSampleStruct;
enum class SampleEnum /* "urn:aaasdf"[GblSmpl] */
{
etNone,
etAFew,
etSome,
etALot
};
class SampleEnum_TypeInfoHolder : public TObject {
SampleEnum __instanceType;
public:
__published:
__property SampleEnum __propType = { read=__instanceType };
};
// ************************************************************************ //
// XML : MySOAPHeader, global, <complexType>
// Namespace : urn:@:aaasdf
// Info : Header
// ************************************************************************ //
class MySOAPHeader : public TSOAPHeader {
private:
UnicodeString FUsername;
UnicodeString FPassword;
__published:
__property UnicodeString Username = { read=FUsername, write=FUsername };
__property UnicodeString Password = { read=FPassword, write=FPassword };
};
// ************************************************************************ //
// XML : TSampleStruct, global, <complexType>
// Namespace : urn:@:aaasdf
// ************************************************************************ //
class TSampleStruct : public TRemotable {
private:
UnicodeString FLastName;
UnicodeString FFirstName;
double FSalary;
__published:
__property UnicodeString LastName = { read=FLastName, write=FLastName };
__property UnicodeString FirstName = { read=FFirstName, write=FFirstName };
__property double Salary = { read=FSalary, write=FSalary };
};
// ************************************************************************ //
// Namespace : urn:aaasdf-Iaaasdf
// soapAction: urn:aaasdf-Iaaasdf#%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// use : encoded
// binding : Iaaasdfbinding
// service : Iaaasdfservice
// port : IaaasdfPort
// URL : http://localhost:8080/soap/Iaaasdf
// ************************************************************************ //
__interface INTERFACE_UUID("{819FEDBA-8C1C-2AAB-5953-DD7A44D3C033}") Iaaasdf : public IInvokable
{
public:
// Headers: MySOAPHeader:pInOut
virtual SampleEnum echoEnum(const SampleEnum eValue) = 0;
// Headers: MySOAPHeader:pInOut
virtual TDoubleDynArray echoDoubleArray(const TDoubleDynArray daValue) = 0;
// Headers: MySOAPHeader:pInOut
virtual TSampleStruct* echoStruct(const TSampleStruct* pEmployee) = 0;
// Headers: MySOAPHeader:pInOut
virtual double echoDouble(const double dValue) = 0;
};
typedef DelphiInterface<Iaaasdf> _di_Iaaasdf;
_di_Iaaasdf GetIaaasdf(bool useWSDL=false, System::String addr= System::String(), Soaphttpclient::THTTPRIO* HTTPRIO=0);
}; // NS_Iaaasdf
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace NS_Iaaasdf;
#endif
#endif // IaaasdfH
Teşekkürler