Whitespace lost when using MTOM message encoding
- Dominant language
- C#
- Stars
- 1.8k
- Forks
- 576
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 2
Description
Whitespace characters are trimmed on all XML content when calling WCF service using MTOM message encoding.
Steps to reproduce the behavior:
1. Host a WCF service using MTOM message encoding.
2. Call a method returning whitespaces from client app.
3. No whitespace is observed on response.
Host app:
```c#
string baseAddress = "http://localhost:8080/wcfselfhost/";
ServiceHost host = new ServiceHost(typeof(HelloWorldService), new Uri(baseAddress));
BasicHttpBinding binding = new BasicHttpBinding();
binding.MessageEncoding = WSMessageEncoding.Mtom;
host.AddServiceEndpoint(typeof(IHelloWorldService), binding, "hello");
host.Open();
Console.ReadLine();
```
Host app service:
```c#
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
string SayHello(string name);
}
public class HelloWorldService : IHelloWorldService
{
public string SayHello(string name)
{
return string.Format(" whitespace hello, {0} ", name);
}
}
```
Test client:
```c#
var channelFactory = new ChannelFactory(
new BasicHttpBinding() { MessageEncoding = WSMessageEncoding.Mtom },
new EndpointAddress("http://localhost:8080/wcfselfhost/hello")
);
var channel = channelFactory.CreateChannel();
string resp = channel.SayHello("test");
Console.ReadKey();
```
Test client is built using .NET 6.0 and System.ServiceModel.Http version 4.9.0.
'resp' variable contents is "whitespace hello, test "
Expected behavior is to get " whitespace hello, test "
Contributor guide
Assessment
This issue has not been assessed yet.