Preventing Deserialization of a WCF Client

I have a WCF proxy that reads from a SOAP web service. I do not control the service, but only the client proxy. The result of calling one of the service operations is defined as a very large XML schema, of which only a small subset matters in my application.

I created a custom WCF behavior that allows me to parse a raw XML response and read only the relevant parts. However, the proxy server still deserializes the response in the object graph (which is quite complicated as a result of the XML schema). As for my application, this last step is redundant.

Can I prevent my WCF proxy from completing the last step of deserializing the response?

+3
source share
3 answers

Where exactly do you want to process the parts of the message you want? In general, it sounds as if you really do not want the proxy server to be generated by default, and you will be better off with your own custom proxy server.

If you can go this route, one of the options available would be to simply force the proxy to return a Message instead of a real DataContract, and then you can easily read the raw XML from the SOAP body and parse it. Easier than trying to mess around with the serializer, imho.

+2
source

Start by defining a ServiceContract client on the client side, for example

[OperationContract(Action="YourAction", ReplyAction="YourResponseAction")]
Message YourMethod(Message request)

generic ClientFactory -.

Message .

+2

I talked about exactly what decision I received. So for completeness:

+1
source

Source: https://habr.com/ru/post/1729556/


All Articles