#1 2013-12-30 14:24:53

AArhin
Member
Registered: 2013-12-30
Posts: 10

Need help to kick Start my project

Dear All,
       I stumbled upon this project whilst looking for alternatives to web services in Delphi 2007.
I need to write a web service that takes a list of transactions in xml format in the form of a string
process them and return the results same as xml string.

Below is a  sample input string :

<Transactions TransactionsCount="1180" TransactionsTotal="36781597.68">
<Transaction TransactionIDX="29066" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000200486301</AccountNumber>
<Amount>11306.00</Amount>
<SerialNumber>129343</SerialNumber>
<Narration>Chq# 129343 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050902</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29067" TransactionType="DB" MessageType="CCC">
<AccountNumber>1002100212101</AccountNumber>
<Amount>58379.40</Amount>
<SerialNumber>444879</SerialNumber>
<Narration>Chq# 444879 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050621</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29068" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000101104701</AccountNumber>
<Amount>20000.00</Amount>
<SerialNumber>599662</SerialNumber>
<Narration>Chq# 599662 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050101</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29069" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000700262901</AccountNumber>
<Amount>3701.07</Amount>
<SerialNumber>708361</SerialNumber>
<Narration>Chq# 708361 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050407</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29070" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000600647501</AccountNumber>
<Amount>500.00</Amount>
<SerialNumber>162320</SerialNumber>
<Narration>Chq# 162320 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050706</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29071" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000200560501</AccountNumber>
<Amount>26544.94</Amount>
<SerialNumber>152879</SerialNumber>
<Narration>Chq# 152879 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050902</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29072" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000600466101</AccountNumber>
<Amount>1000.00</Amount>
<SerialNumber>133420</SerialNumber>
<Narration>Chq# 133420 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050706</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29073" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000600800101</AccountNumber>
<Amount>4991.60</Amount>
<SerialNumber>124728</SerialNumber>
<Narration>Chq# 124728 ifo </Narration>
<TransactionCode>01</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050706</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29074" TransactionType="DB" MessageType="CCC">
<AccountNumber>1002700057701</AccountNumber>
<Amount>456.20</Amount>
<SerialNumber>252250</SerialNumber>
<Narration>Chq# 252250 ifo </Narration>
<TransactionCode>01</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050327</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29075" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000600812301</AccountNumber>
<Amount>1200.00</Amount>
<SerialNumber>163001</SerialNumber>
<Narration>Chq# 163001 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050706</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29076" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000600473501</AccountNumber>
<Amount>778.57</Amount>
<SerialNumber>155084</SerialNumber>
<Narration>Chq# 155084 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050706</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29077" TransactionType="DB" MessageType="CCC">
<AccountNumber>1000101005001</AccountNumber>
<Amount>123.70</Amount>
<SerialNumber>615584</SerialNumber>
<Narration>Chq# 615584 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050101</BranchSortCode>
</Transaction>
<Transaction TransactionIDX="29078" TransactionType="DB" MessageType="CCC">
<AccountNumber>1002100151801</AccountNumber>
<Amount>220000.00</Amount>
<SerialNumber>446191</SerialNumber>
<Narration>Chq# 446191 ifo </Narration>
<TransactionCode>02</TransactionCode>
<Currency>GHS</Currency>
<BranchSortCode>050621</BranchSortCode>
</Transaction>
</Transactions>

Any help will be very much appreciated.
Thanks.

Offline

#2 2013-12-30 14:42:08

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Need help to kick Start my project

mORMot does not use XML, but JSON.
There is no built-in support of XML in our classes.

If you can switch to JSON - which is lighter and native to AJAX web services - you can use our classes.
And with our record-based JSON serializer, it is very easy to work with such content.
See http://blog.synopse.info/post/2013/12/1 … ialization

Offline

#3 2013-12-30 15:24:11

AArhin
Member
Registered: 2013-12-30
Posts: 10

Re: Need help to kick Start my project

Thanks for the quick response.

I am very much prepared to switch to JASON that is why I am here.
I would like to create a gui based server that can run as stand alone app or service app for starters.
I do not intend to use any database operations.
Actually this  server will act like a sort of proxy to service request / response to an external application using socket commands.

Any pointers to classes to use and gotchas ?

Thanks

Offline

#4 2013-12-30 15:26:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Need help to kick Start my project

I suppose you need an HTTP server, which will act as a proxy, right?

What is the exact process on the JSON content?

If there is no process (just send back the same data), you don't need to switch to JSON, just use the SynCrtSock.pas unit, and its HTTP.sys based server.

Offline

#5 2013-12-30 16:55:57

AArhin
Member
Registered: 2013-12-30
Posts: 10

Re: Need help to kick Start my project

Let me put the app in context. There is an Asta based multi tier app that has been running for more than 10 yrs now.
The client is changing their core app (CBS) to a new one that external apps can interface with using a custom defined message format or iso8583.
Now I figure that instead each client app issuing transactions directly to the core app, I would rather design a web service that clients could forward their transactions to in the form of a string in xml format as posted above.
The web service will then post each transaction to the CBS in the desired format via sockets (indy blocking) and receive each posting result format them as xml data and send them back to the client.

That basically is my design.

I am open to alternatives that will not mean I need to do a lot more changes to the client apps.

thanks

Offline

#6 2013-12-31 15:31:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Need help to kick Start my project

Ensure you take at least a quick look at our SAD 1.18 pdf.
http://synopse.info/files/pdf/Synopse%2 … 201.18.pdf
The first pages gives some idea about the concepts and design patterns used in mORMot.
If you do not need any database, just ignore the corresponding part (i.e. ORM and database).
But focus on services.

In mORMot, you have two kind of services:
- method-based services;
- interface-based services.
The 1st gives full power to the process, but you need more work in your code (e.g. to marshall parameters).
The 2nd are perhaps easiest to work with, and create pretty simple JSON web services.

For JSON serialization, see http://blog.synopse.info/post/2013/12/1 … ialization
You could define your data structure as such:

type
  TTransactions = packed record
    TransactionsCount: cardinal;
    TransactionsTotal: currency;
    Transaction: array of packed record
      TransactionIDX: cardinal;
      TransactionType: RawUTF8; // or string
      MessageType: RawUTF8;
      AccountNumber: Int64;
      Amount: currency;
      SerialNumber: cardinal;
      Narration: RawUTF8;
      TransactionCode: cardinal;
      Currency: RawUTF8;
      BranchSortCode: RawUTF8;
    end;
  end;

Offline

Board footer

Powered by FluxBB