Here are some thoughts for a secure mounting of a contact sensor to the surface of a soft case.
Purchase a small amount of 1/16" thick PVC plastic for the mounting bases (1/8" will work but is harder to work with).
Cut a rectangular piece of plastic for each part of the sensor and drill or melt-in holes around the perimeter. Using PVC glue attach each part of the sensor to its mounting base. Keep in mind that contact along the flat edges is where the magnetic action is to occur and glue accordingly.
Next, stitch one part of the sensing unit to one side of the case seam and the other part to the opposite side of the seam. I think sewing them on the inside of the case is better. See the diagram below:
Instead of buying cutting and drilling pieces of plastic, 3D-print it for a more compact form with smaller threading holes closer to the edges. ABS plastic would be a good choice of plastic along with some other types that would have to be researched.
3D-printed heavy screen-like bases would permit gluing the sensors to one side of the base with ABS/PVC glue and the other side of the base to the fabric with epoxy or a specialty adhesive.
Or dispense with sewing the base to the fabric and attach it with non-magnetic cloth rivets.
Before doing any of the above, check to see if the closing methods of the soft case such as buttons, zippers, snaps, laces, or latches will interfere with the magnetic operation of the contact sensor.