tags:

views:

15

answers:

1

Hello! i have 2 projects. First project send to 2-nd via http-post requests, as serialized to XML class instances.

Ex:

<?xml version="1.0" encoding="utf-16"?>
<MyObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
<UserId>test user</UserId>
...

How can i recieve it in action of 2-nd project?

[HttpPost]
public ActionResult Index(MyObject id)
{ ...

or like string, and deserialize after?

Thanx.

+1  A: 

I would try to refactor this to JSON POST call. But yes, you can send xml data as string and deserealize it on server.

Andrew Florko
Unfortunately, ActionResult Index(string id) returns null.Any ideas?
Maxim
Can you give client code example how do you send data.
Andrew Florko
StringWriter writer = new StringWriter(); XmlSerializer x = new XmlSerializer(typeof(MyObject)); x.Serialize(writer, lo); if (writer != null) { byte[] byteData = UTF8Encoding.UTF8.GetBytes(writer.ToString());........Send via HttpWebRequest
Maxim
I've never implemented call this way but I suppose you shall construct post data the way your byte array is associated with id parameter. May be this article will be usefull:http://www.jigar.net/howdoi/viewhtmlcontent106.aspxTry to use WCF contract-based communication instead of creating post call by hands.
Andrew Florko