In WW-2 there were several encouters between the coastal batteries and warships.
During the invasion of Norway, the German heavy cruiser "Blücher" was
put out of action by the Norwegian coastal battery at Kaholm.
Ironicly her 28 cm guns were
made by "Krupp". A 45 cm torpedobattery finished the job and the
"Blücher" sank. The "Raid on Dieppe" took place in 1942 when there was no real
Atlanticwall built yet.
When the allies sailed to St Nazaire in March 1942, there was a short
artillery duel with the German battery at Fort de l' Eve, which ended in a draw.
Keep in mind that in the early years the German guns were in open emplacements and the
allied firepower was limited to 10 cm. The first real encouter was D-Day, where due to the vast allied fleet with the
heavy battleships and the airsuperiority, the "few" German batteries were no match.
The battery at Longues sur Mer had a few fights with cruisers. Most damage was caused by the
inlandbatteries which were pre-sited for the beaches. A few improvised gunspositions of coastal
batteries, such as two 21 cm guns in the battery St Marcouf / Crisbecque, were also firing
shells at the unprotected soldiers approaching the strongholts in the high terrain of Omaha beach.
In the first days after the landings the floating artillery gave massive fire support to the troops fighting their way inland. After D-Day encouters took place during the liberation of some harbours on the French coast. The fortresses Cherbourg and Le Havre were attacked from the sea. The battery at Néville-sur-Mer had some duels with allied battleships.
As part of the operation "Dragoon" an allied fleet supported the actions in southern France. In this part of the "Südwall" the battery at Cap Cépet with 4 French guns of 34 cm fired over 200 rounds at the allied fleet. One of the 2 battleships in the fleet was the French "Lorraine", which was equipped with the same type of guns as in the opposing battery. Groundforces conquered the German position of which the guns were found to be fully intact.
One of the last encounters took place at the landings on the Dutch island of Walcheren. This operation had to clear the "Scheldt" from coastal batteries and mines, in order to use the harbour of Antwerpen. At Westkapelle the old lady "Warspite" with the monitors "Erebus" and "Roberts", brought 10 working 38 cm guns in action against 4 German naval coastal batteries:
The heavy allied artillery ships were positionned out of range of the German guns and although they could not destroy the guncasemates, they certainly suppressed the enemy fire on the landingbeaches. As a "lesson learned" in Normandy, the allied forces disabled the numerous inland batteries on Walcheren by flooding the island.
At the end of the war, in april 1945, French troops tried to liberate the Festung "Gironde Nord". The French battleship "Lorraine" with her 8 rather good 34 cm guns sailed in for the artillery support. There was a small duel with the German battery at "Fort du Suzac", but as the infantery could not advance, due to the massive Landfront defences and the operation was cancelled. It is an old military law: you need infantery to conquer terrain and keep it in under control.
All of Germany's big efforts in building numerous coastal batteries did not have the effect that was expected. As a defenceline along the European coast, the Atlanticwall, stood on its own and had no support from airforce or surface navy. The concept of building heavily fortified fortresses (Festungen) at the major harbours did however work. This had everything to do with the strong defences in the "Landfronts". The liberation of Cherbourg costed the Us troops so many casualties, that the question remains if the final result, using the small harbour of Cherbourg, was worth these causualties. Several of the other Festungen, mostly the former U-boat harbours, were sealed off and left alone by the allies. St Nazaire, Lorient and some parts around the Gironde, did not surrender before Germany in total did.
The same goes for the Channel Islands.