Patch level :
Files correlati : ba3.exe cg0.exe cg2.exe ve0.exe Ricompilazione Demo : [ ] Commento : Implementata la spedizione delle trnsazione via socket in formato SOAP git-svn-id: svn://10.65.10.50/trunk@15843 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0c9102a75f
commit
cc8c97ada8
@ -1,10 +1,12 @@
|
|||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <expr.h>
|
#include <expr.h>
|
||||||
#include <golem.h>
|
#include <golem.h>
|
||||||
|
#include <netsock.h>
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
#include <scanner.h>
|
#include <scanner.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
#include <xml.h>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TRecipient
|
// TRecipient
|
||||||
@ -168,6 +170,57 @@ bool TPostman::can_dispatch_transaction(const TRectype& rec)
|
|||||||
return _recipient.items() > 0;
|
return _recipient.items() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int write_xml(TConfig& cfg, void* jolly)
|
||||||
|
{
|
||||||
|
TAssoc_array &vars = cfg.list_variables();
|
||||||
|
TXmlItem &item = *(TXmlItem *) jolly;
|
||||||
|
TToken_string tag(cfg.get_paragraph(), ',');
|
||||||
|
const int logicnum = tag.get_int();
|
||||||
|
const char * attr = logicnum > 0 ? "Field" : "Attr";
|
||||||
|
int rownum = tag.get_int();
|
||||||
|
|
||||||
|
if (logicnum > 0)
|
||||||
|
tag = "Record";
|
||||||
|
TXmlItem & child =item.AddChild(tag);
|
||||||
|
if (logicnum > 0)
|
||||||
|
{
|
||||||
|
child.SetAttr("LogicNumber", logicnum);
|
||||||
|
child.SetAttr("TableName", logic2table(logicnum));
|
||||||
|
|
||||||
|
|
||||||
|
if (rownum > 0)
|
||||||
|
child.SetAttr("RowNumber", rownum);
|
||||||
|
}
|
||||||
|
|
||||||
|
TString s;
|
||||||
|
|
||||||
|
FOR_EACH_ASSOC_STRING(vars, hobj, key, val)
|
||||||
|
if (val && *val)
|
||||||
|
{
|
||||||
|
s = val;
|
||||||
|
if (s[0] == '"' && s.ends_with("\""))
|
||||||
|
{
|
||||||
|
s.rtrim(1);
|
||||||
|
s.ltrim(1);
|
||||||
|
}
|
||||||
|
s.trim();
|
||||||
|
if (TDate::isdate(s))
|
||||||
|
{
|
||||||
|
TDate date(s);
|
||||||
|
|
||||||
|
child.AddSoapInt(attr, date.date2ansi()).SetAttr("Name", key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (real::is_natural(s))
|
||||||
|
child.AddSoapInt(attr, atoi(s)).SetAttr("Name", key);
|
||||||
|
else
|
||||||
|
child.AddSoapString(attr, s).SetAttr("Name", key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool TPostman::dispatch_transaction(const TRectype& rec,
|
bool TPostman::dispatch_transaction(const TRectype& rec,
|
||||||
const TFilename& name)
|
const TFilename& name)
|
||||||
{
|
{
|
||||||
@ -176,6 +229,7 @@ bool TPostman::dispatch_transaction(const TRectype& rec,
|
|||||||
{
|
{
|
||||||
TToken_string dest;
|
TToken_string dest;
|
||||||
TToken_string file_dest;
|
TToken_string file_dest;
|
||||||
|
TToken_string soap_dest;
|
||||||
TString last_error;
|
TString last_error;
|
||||||
|
|
||||||
for (int r = 0; r < _recipient.items(); r++)
|
for (int r = 0; r < _recipient.items(); r++)
|
||||||
@ -186,6 +240,8 @@ bool TPostman::dispatch_transaction(const TRectype& rec,
|
|||||||
const TString& addr = a.address();
|
const TString& addr = a.address();
|
||||||
if (addr.find('@') >= 0) // Indirizzo posta
|
if (addr.find('@') >= 0) // Indirizzo posta
|
||||||
dest.add(addr);
|
dest.add(addr);
|
||||||
|
if (addr.starts_with("http")) // Indirizzo http
|
||||||
|
soap_dest.add(addr);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fexist(addr))
|
if (fexist(addr))
|
||||||
@ -258,6 +314,53 @@ bool TPostman::dispatch_transaction(const TRectype& rec,
|
|||||||
ok = fcopy(name, output);
|
ok = fcopy(name, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (soap_dest.items() > 0)
|
||||||
|
{
|
||||||
|
TConfig trans(name);
|
||||||
|
TXmlItem item;
|
||||||
|
TSocketClient socket;
|
||||||
|
char * buf = new char[1024 * 256];
|
||||||
|
strstream stream(buf, 1024 * 256);
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
|
item.SetTag("Campo");
|
||||||
|
trans.for_each_paragraph(write_xml, &item);
|
||||||
|
|
||||||
|
item.Write(stream, 0);
|
||||||
|
stream << '\0';
|
||||||
|
|
||||||
|
#ifdef DBG
|
||||||
|
TFilename name;
|
||||||
|
char hostname[256];
|
||||||
|
int len = strlen(buf);
|
||||||
|
|
||||||
|
len += 79;
|
||||||
|
xvt_sys_get_host_name(hostname, sizeof(hostname));
|
||||||
|
|
||||||
|
name.temp();
|
||||||
|
|
||||||
|
ofstream f(name);
|
||||||
|
|
||||||
|
f << "POST / HTTP/1.1\n"
|
||||||
|
<< "User-Agent: Campo\n"
|
||||||
|
<< "Host: " << hostname << "\n"
|
||||||
|
<< "Content-Type: text/xml; charset=utf-8\n"
|
||||||
|
<< "Content-length: " << len << "\n"
|
||||||
|
<< "SOAPAction: \"/\"\r\n\r\n"
|
||||||
|
<< "<SOAP-ENV:Envelope>\n<SOAP-ENV:Body>\n";
|
||||||
|
|
||||||
|
item.Write(f, 0);
|
||||||
|
|
||||||
|
f << "\n</SOAP-ENV:Body>\n</SOAP-ENV:Envelope>\r\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FOR_EACH_TOKEN(soap_dest, r)
|
||||||
|
{
|
||||||
|
CONNID id = socket.QueryConnection("", r);
|
||||||
|
socket.HttpSoap(id, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -343,6 +343,7 @@ TXmlItem& TXmlItem::AddSoapString(const char* name, const char* value, bool typi
|
|||||||
TXmlItem& xmlVar = AddChild(name);
|
TXmlItem& xmlVar = AddChild(name);
|
||||||
if (typized)
|
if (typized)
|
||||||
xmlVar.SetAttr("xsi:type", "xsd:string");
|
xmlVar.SetAttr("xsi:type", "xsd:string");
|
||||||
|
if (value && *value)
|
||||||
xmlVar.AddChild("").SetText(value);
|
xmlVar.AddChild("").SetText(value);
|
||||||
return xmlVar;
|
return xmlVar;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user