views:

30

answers:

1

Client:

string value = "<?xml version=1.0?><person><firstname>john</firstname><lastname>smith</lastname> <person/>";

using (HttpResponseMessage response = m_RestHttpClient.Post("new/customerxml/"+value2, frm.CreateHttpContent()))
{

}

Server:

[OperationContract]
[WebInvoke(UriTemplate = "new/customerxml/string={value}", Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)]
public string NewCustomer(string value)
{
        return value;
}
+1  A: 

That's because WCF sniffs the content and decides you are uploading XML, not a string. Assuming you are using the HttpClient from the WCF REST Starter kit, try this:

    string value = "<?xml version=1.0?><person><firstname>john</firstname><lastname>smith</lastname> <person/>";

var content = HttpContentExtentions.CreateDataContract(value, typeof(string));
using (HttpResponseMessage response = m_RestHttpClient.Post("new/customerxml/"+value2, content)
    {
      ...
    }
Darrel Miller