views:

19

answers:

2

When invoking a service, my client code passes in data. One of the data members is a byte array, so WCF will automatically encode this into a base-64 string during serialization. The problem is, the data contract of the service is expecting a byte array, not a string, so deserialization of the data will result in an exception: Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''

How do I work around this glitch?

A: 

I'm not sure I understand what you mean? What does the contract for your service look like? I very much doubt the problem is the base-64 serialization, unless your service is expecting the binary data encoded in hexbinary format instead.

Remember, you're using XML here, so binary data can't travel unencoded; it needs to be serialized into a text format that can be embedded in the SOAP envelope (unless you're using MTOM), and that's usually Base-64.

tomasr
A: 

It can be caused by a mismatch between client and service. Did you try refreshing your client proxy (by updating the service reference for example)?

Johann Blais