使用API​​ POST:REST Web服务:正文序列化

时间:2011-11-23 19:31:06

标签: wcf rest biztalk

我正在尝试使用REST网络服务,请遵循以下指示:http://social.technet.microsoft.com/wiki/contents/articles/invoke-restful-web-services-with-biztalk-server-2010.aspx

然而,GET似乎工作正常,但POST失败了,因为不知何故,消息被序列化为字符串。

我明白了:

POST /my_app/12005ab0-1522-71e1-0dde-0a0801c50000 HTTP/1.1
Content-Type: application/xml; charset=utf-8
Host: bsmshell.inovaprime.com:81
Content-Length: 174
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">&lt;body xmlns="http://microsoft.com/schemas/samples/biztalkwebhttp/1.0"&gt;HelloWorld&lt;/body&gt;</string>

而不是:

POST /my_app/12005ab0-1522-71e1-0dde-0a0801c50000 HTTP/1.1
Content-Type: application/xml; charset=utf-8
Host: bsmshell.inovaprime.com:81
Content-Length: 174
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

<body xmlns="http://microsoft.com/schemas/samples/biztalkwebhttp/1.0">HelloWorld</body>

这有以下消息:                    12005ab0-1522-71e1-0dde-0a0801c50000        应用/ XML;字符集= utf-8的        你好,世界      

端口配置如文章所示。

关于我看到这种行为的可能原因的任何指示?

由于

2 个答案:

答案 0 :(得分:1)

Message.CreateMessage(request.Version,request.Headers.Action,bodyElement.ToString());将其更改为:Message.CreateMessage(request.Version,request.Headers.Action,bodyElement);解决了这个问题。

[按顺序发布其他人查找]

答案 1 :(得分:0)

原因是content-type