Posts by campbellpeter

I am a Christian living in West Cumbria. I am an application developer for a local firm. I am married and have 2 kids and enjoy playing computer games, working out, reading and writing. I am Treasurer and a deacon for Woodbank Community Church

Polly: The fallback position

Parrot flying with Eagles

How many times in an application dependent on some external resource do you have to write a function or a maybe a whole module to deal with fallback cases? Perhaps the web service you call is down and you fallback to data cached from the last call, or a ftp site is not available so you send the third-party an automatic email to notify them. As developers we are constantly coding fallbacks.

Last week I gave a brief introduction to Polly a fault handling library built for .Net Standard and .Net Core. We looked at the wait and retry functionality that the library has, which would be useful if the external resource is having a blip, but what about if it is down, how do we gracefully degrade?

Continue reading →

Polly Introductions

Parrot flying with Eagles

Photo by Alexandre Debiève on Unsplash

Having seen mention of Polly on Scott Hanselmann’s blog and heard Dylan Reisenberger enthusiastically talk about it on  .Net Rocks, I was keen to have a look at this library and see what it can do.

Any type of integration relies on an IO operation that often out of control of the developer, we use web services that can go down, open and read files from remote servers that can be suddenly inaccessible, rely on database connections that can drop. Adding code to deal with this has always been essential to any integration module.

As an example I have created small console application that opens and reads an excel file, that is already open causing an IOException. I will add the Polly library to this and set up a policy to retry the operation while prompting the user to close the file.

Continue reading →

Upload files to FTP using the WINSCP .Net library

elevator-2203695_960_720

Applications like Filezilla and WinSCP are great simple to use FTP/SFTP clients. However what about if you want to automate uploading files. Imagine you have a brilliant SSIS package, that extracts, manipulates and formats just the right data into the correct format, using SQL Server agent to run  your package early in the morning to take advantage of the gap in transactions hitting the database server. You want these extracted data files to be sent to a third party without you needing to log in open WINSCP  or Filezilla and manually upload them.

That is what we are going to look at today, a few simple methods for zipping some files and uploading them in an application that can then be set to run on a schedule with something like Windows Task Scheduler.

Continue reading →

AX Integration: Royal Mail Shipping API Part 5 – Security

RoyalMail               Dyn-AX12_v_rgb

We are building an integration between the Royal Mail SOAP Shipping API and Microsoft Dynamics AX 2012 R2. In parts 1-3 we have built a C# component to add some helper methods for interacting with the Royal Mail client proxy. In part 4 we called this client proxy in X++ and used our helper methods to extend the headers we send with the request message.

Now that we have the service client, we need to add WS Security headers to the request message to pass the Royal Mail authentication.

Continue reading →

AX Integration: Royal Mail Shipping API Part 4

RoyalMail               Dyn-AX12_v_rgb

We are building an integration between the Royal Mail SOAP Shipping API and Microsoft Dynamics AX 2012 R2. In parts 1 , 2 and 3 we have built using Windows Communication Foundation (WCF) some components to handle SOAP elements we need to add to the request message and security headers.

In this part we are going to create a proxy client in X++ and call some of the code we have previously written. We are going to take advantage of X++ ability to use .Net assemblies, including the code we have previously created and deployed to the AOT.

Note: I am going to show the declaration of variables alongside the assignation, getting and setting of the objects, for ease of explanation. However in X++ all variables are declared at the top of the method. The summary of the method at the end of the article will show the proper structure.

Continue reading →