0

I would like to have all strings in inbound WCF messages trimmed, so that I don't have to worry about trimming them in all of my operations. I can accomplish this with an IParameterInspector and a lot of delicate reflection logic, but it seems like there must be a better way.

I have tried using an IDataContractSurrogate, but the GetDeserializedObject does not get called for string deserialization.

Is there another way to hook into DataContractSerializer that would let me modify strings without massive reflection?

Annabelle
  • 10,596
  • 5
  • 27
  • 26
  • Sounds dangerous from a maintenance perspective. But it also sounds interesting, and I like to live dangerously. –  Mar 04 '11 at 22:31

1 Answers1

0
  1. You can do this by implementing IXMLSerializable. Go through this question. Of course, you need implement ReadXml operation.

  2. Whats stopping you to cast the object and updating it while inspecting the Parameter?

  3. If you think the service is used by specific .Net consumers, you can create a wcf service client, add your trimming logic to it and distribute it (so that consumers can directly make use of client instead of creating a proxy to your service). One side affect with this is you have to redistribute the client dlls whenever there is a change in the contract.

Community
  • 1
  • 1
user635388
  • 88
  • 3