WCF学习问题之:响应消息的内容类型 multipart/related; type="application/xop+xml"……

继续WCF路由测试样例,错误提示:

响应消息的内容类型 multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:da79eb0e-af0d-4754-8e19-474b1261a624+id=2";start-info="text/xml" 与绑定(text/xml; charset=utf-8)的内容类型不匹配。如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法。响应的前 1024 个字节为:“

--uuid:da79eb0e-af0d-4754-8e19-474b1261a624+id=2

Content-ID: <http://tempuri.org/0>

Content-Transfer-Encoding: 8bit

Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

后来发现还是路由时的绑定配置问题,我的路由样例是wsHttpBinding绑定去路由两个BasicHttpBinding绑定,而BasicHttpBinding绑定中实现的是文件的上传和下载。由于在BasicHttpBinding中使用了messageEncoding="Mtom",而在路由的时候没有增加所以报错……

后来在路由中,增加了相应的配置,即解决了问题。

                BasicHttpBinding tc = new BasicHttpBinding();
                tc.TransferMode = TransferMode.Streamed;
                tc.MessageEncoding = WSMessageEncoding.Mtom;


 

posted @ 2013-11-18 10:38  了了之  阅读(4528)  评论(0编辑  收藏  举报