Saturday, November 21. 2009
Writing DTAUS files with C# (DTA-Dateien mit C# erzeugen)
In germany there is a file format for transfering bank transaction requests called DTAUS. I recently had the need to create such a file programatically, so I searched if anyone else already managed this task.
What I found was a blog entry of Timotheus Pokorra who wrote a litte C# class that managed this task for direct debits.
He generously allows anyone to use this class and provides his source code as download.
For my task, I extended his code to work with C# data objects instead of Xml data structures and added some optimizations and extensions.
The result is a set of three classes to create bank transfer or direct debit requests and allow them to be exported into to DTAUS fiel format with complete code documentation.
Of course, I will not hesitate to give back my extensions to the great work to Timotheus and the remaining web community.
Nevertheless, I do not want this class to be sold by others, so the license is Creative Commons NC-BY-SA. If you want to simply use my code in another (even sold) product, please contact me, if your product is more than "a library for DTAUS file management", I should gracefully permit you the right to use it.
(Download after german translation)
If you need a binary version of the file, just post me a line using the comments function of the blog.
Vor kurzem Stand ich vor der Aufgabe, in einem von mir geschriebenen Programm DTA-Dateien schreiben zu können, die in Deutschland verwendet werden, um Bankeinzug oder Überweisungsaufträge an Banken zu übermitteln. Nach einigem Suchen fand ich im Blog von Timotheus Pokorra eine Codedatei, die genau diese Aufgabe in C# erledigt. Der Code war für Xml-Strukturen als Eingabe entwickelt und darf frei verwendet werden.
Ich habe diese Klasse ein wenig erweitert, optimiert, Fehler ausgebügelt und zwei Datenobjekte erstellt, mit denen die Daten für den DTA-Auftrag in C#-Strukturen gespeichert werden können.
Gerne stelle ich meine Erweiterungen auch wieder frei zur Verfügung, solange die Anwendung nichtkommerziell ist (Creative Commons NC-BY-SA). Wer sie in kommerziellen Produkten einsetzen will, nimmt bitte Kontakt mit mir auf, ich bin gerne bereit, auch dafür die Freigabe zu erteilen, solange es nicht um eine Bibliothek zur DTA-Verwaltung geht...
Wer eine kompilierte Version benötigt, darf sich gerne über die Kommentarfunktion bei mir melden.
You can find the Library here: DTAUSWriter.cs
Download der DTA-Datei-Bibliothek: DTAUSWriter.cs

DTAUS Writer classes for C# von Timotheus Pokorra & Florian Harbich steht unter einer Creative Commons Namensnennung-Keine kommerzielle Nutzung-Weitergabe unter gleichen Bedingungen 3.0 Deutschland Lizenz.
Beruht auf einem Inhalt unter tpokorra.blogspot.com.
What I found was a blog entry of Timotheus Pokorra who wrote a litte C# class that managed this task for direct debits.
He generously allows anyone to use this class and provides his source code as download.
For my task, I extended his code to work with C# data objects instead of Xml data structures and added some optimizations and extensions.
The result is a set of three classes to create bank transfer or direct debit requests and allow them to be exported into to DTAUS fiel format with complete code documentation.
Of course, I will not hesitate to give back my extensions to the great work to Timotheus and the remaining web community.
Nevertheless, I do not want this class to be sold by others, so the license is Creative Commons NC-BY-SA. If you want to simply use my code in another (even sold) product, please contact me, if your product is more than "a library for DTAUS file management", I should gracefully permit you the right to use it.
(Download after german translation)
If you need a binary version of the file, just post me a line using the comments function of the blog.
Vor kurzem Stand ich vor der Aufgabe, in einem von mir geschriebenen Programm DTA-Dateien schreiben zu können, die in Deutschland verwendet werden, um Bankeinzug oder Überweisungsaufträge an Banken zu übermitteln. Nach einigem Suchen fand ich im Blog von Timotheus Pokorra eine Codedatei, die genau diese Aufgabe in C# erledigt. Der Code war für Xml-Strukturen als Eingabe entwickelt und darf frei verwendet werden.
Ich habe diese Klasse ein wenig erweitert, optimiert, Fehler ausgebügelt und zwei Datenobjekte erstellt, mit denen die Daten für den DTA-Auftrag in C#-Strukturen gespeichert werden können.
Gerne stelle ich meine Erweiterungen auch wieder frei zur Verfügung, solange die Anwendung nichtkommerziell ist (Creative Commons NC-BY-SA). Wer sie in kommerziellen Produkten einsetzen will, nimmt bitte Kontakt mit mir auf, ich bin gerne bereit, auch dafür die Freigabe zu erteilen, solange es nicht um eine Bibliothek zur DTA-Verwaltung geht...
Wer eine kompilierte Version benötigt, darf sich gerne über die Kommentarfunktion bei mir melden.
You can find the Library here: DTAUSWriter.cs
Download der DTA-Datei-Bibliothek: DTAUSWriter.cs

DTAUS Writer classes for C# von Timotheus Pokorra & Florian Harbich steht unter einer Creative Commons Namensnennung-Keine kommerzielle Nutzung-Weitergabe unter gleichen Bedingungen 3.0 Deutschland Lizenz.
Beruht auf einem Inhalt unter tpokorra.blogspot.com.
Thursday, March 26. 2009
WCF Peer-To-Peer (PNRP) under Windows Server 2008
Some days ago on my job I was in charge of extending a legacy .net application to be able to run synchronously on serveral windows server 2008 (standard edition) hosts.
This had to be implemented because of changes to the underlaying host topology (in fact, an standalone webserver was turned into a server farm).
I decided to create a new interface DLL as an adapter to the existing app and use the Microsoft WCF (or "dot-c-f", as they like to call it) API to the PNRP service.
The use of a peer-to-peer architecture made the changes lightweight.
The development of the WCF Interface under windows vista (my development box) went quite well and worked almost immediately.
But the problems came up when I deployed the whole thing to my to win2008 hosts. No peer-to-peer communication was possible, and – even worse – the peers didn't even change their state to "connected" (meaning in microsoft speach that they aren't "alone"), although a connection via TCP and IPv6 was possible between both of the hosts.
This lead my search torwards searching for an infrastructure problem. After googling several results saying that PNRP wasn't possible under win2008 - which I couldn't imagine myself - the solution was finally pretty simple: you just have to install and enable three needed windows services:
1. peer name resolution server (install via server management center as new feature)
2. peer discovery server (same point as above)
3. (not mentioned by MSDN!) the SSDP Service has to be enabled and startet. It is not startet automatically with the PNRP service as there is no service dependency! (Simply change the service start option to Automatically.)
Be sure that all three services are running (and are startet upon system startup) and all your hosts will automagically go into the "connected" state on the LinkLocal-Peer-To-Peer-Cloud.
If you don't know what the SSDP Service is good for: don't mind, I don't either. When you're looking at Wikipedia you will find that SSDP stands for "Simple Service Discovery Protocol" and it is usually used for UPnP Device Discovery. Seems like some creative microsoft programmer decided to use this service in WCF without documenting it!
Finally two more hints, if you're new to WCF P2P Programming:
This had to be implemented because of changes to the underlaying host topology (in fact, an standalone webserver was turned into a server farm).
I decided to create a new interface DLL as an adapter to the existing app and use the Microsoft WCF (or "dot-c-f", as they like to call it) API to the PNRP service.
The use of a peer-to-peer architecture made the changes lightweight.
The development of the WCF Interface under windows vista (my development box) went quite well and worked almost immediately.
But the problems came up when I deployed the whole thing to my to win2008 hosts. No peer-to-peer communication was possible, and – even worse – the peers didn't even change their state to "connected" (meaning in microsoft speach that they aren't "alone"), although a connection via TCP and IPv6 was possible between both of the hosts.
This lead my search torwards searching for an infrastructure problem. After googling several results saying that PNRP wasn't possible under win2008 - which I couldn't imagine myself - the solution was finally pretty simple: you just have to install and enable three needed windows services:
1. peer name resolution server (install via server management center as new feature)
2. peer discovery server (same point as above)
3. (not mentioned by MSDN!) the SSDP Service has to be enabled and startet. It is not startet automatically with the PNRP service as there is no service dependency! (Simply change the service start option to Automatically.)
Be sure that all three services are running (and are startet upon system startup) and all your hosts will automagically go into the "connected" state on the LinkLocal-Peer-To-Peer-Cloud.
If you don't know what the SSDP Service is good for: don't mind, I don't either. When you're looking at Wikipedia you will find that SSDP stands for "Simple Service Discovery Protocol" and it is usually used for UPnP Device Discovery. Seems like some creative microsoft programmer decided to use this service in WCF without documenting it!
Finally two more hints, if you're new to WCF P2P Programming:
- Better turn off the windows firewall, as it is blocking the IPv4 to V6 Teredo tunneling driver. Be sure that IPv6 is supported by your network infrastructure, as it is mandatory for the PNRP protocol.
- Don't forget a config flag in your app to disable the p2p functions, as there will always be a collegue that is wondering where the heck these "random" informations came from (if he's not aware of other peers running in the same cloud, doing some crazy buggy stuff).
Wednesday, February 11. 2009
WCF Service Hosting - Enpoint Hostnames
When you have to specify an address for an WCF Endpoint using the NetTcpBinding, you have to specify a hostname:
As most bindings do, also the NetTcpBinding has a Property called HostNameComparisonMode.
The default value HostNameComparisonMode.StrongWildcard means that any host name (or ip) associated with
the computer described using the given hostname will match this endpoint (here: localhost)!
So in the example above, the Service will also be reachable via 192.168.23.42:12564 (given the "localhost" has this IP address).
(via msdn magazine (german))
Uri listenUri = new Uri("net.tcp://localhost:12564/");
ServiceHost sh = new ServiceHost(typeof(MyService), listenUri);
ServiceEndpoint ep = sh.AddServiceEndpoint(typeof(IMyService),
new NetTcpBinding(SecurityMode.None),
"MyService");
sh.Open();
As most bindings do, also the NetTcpBinding has a Property called HostNameComparisonMode.
The default value HostNameComparisonMode.StrongWildcard means that any host name (or ip) associated with
the computer described using the given hostname will match this endpoint (here: localhost)!
So in the example above, the Service will also be reachable via 192.168.23.42:12564 (given the "localhost" has this IP address).
(via msdn magazine (german))


/* Comments */