WCF DataContractSerializer doesn't pick up contract attributes… why not?

我怕爱的太早我们不能终老 提交于 2019-12-03 20:00:20

It's because message contracts are not data contracts, data contracts use different attributes to mark their classes. Try using a typed message converter;

EchoRequest echoRequest = new EchoRequest{ value = "Hello" };

TypedMessageConverter echoMessageConverter = TypedMessageConverter.Create(
                 typeof(echoRequest),
                 "YourActionNameHere",
                 "http://example.com/services");
Message request = echoMessageConverter.ToMessage(
    echoRequest,MessageVersion.Soap11);

You'll then have a message all ready to go and can pull the request body out if you need to.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!