I have the following method in my WCF service:
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)]
public int GetOne(string param1, string param2)
{
return 1;
}
I am sending xml from a Flex application, and it takes an object that looks like this: { param1: "test", param2: "test2" }
and turns it into the following request:
POST http://localhost:8012/MyService.svc/GetOne HTTP/1.1
Accept: application/xml
Accept-Language: en-US
x-flash-version: 10,1,53,64
Content-Type: application/xml
Content-Length: 52
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Host: localhost:8012
Connection: Keep-Alive
Pragma: no-cache
Cookie: ASP.NET_SessionId=drsynacw0ignepk4ya4pou23
<param1>something</param1><param2>something</param2>
I get the error The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'.
. Everything I've read indicates that I just need the content-type to be application/xml
, but it still thinks it's Raw for some reason. Given my method signature, I'm confused as to what it's expecting and how I need to form the request so it will accept it as XML.
Am I missing something obvious here? Why does it think it's RAW when it's specifying XML and providing XML?
Edit - Here's the Flex side in case I'm missing something here.
var getOneService:HttpService = new HttpService("myURL");
getOneService.method = "POST";
getOneService.resultFormat = "e4x";
getOneService.contentType = HTTPService.CONTENT_TYPE_XML;
getOneService.headers = { Accept: "application/xml" };
getOneService.send({ param1: "test", param2: "test2" });
{ param1: "test", param2: "test2" }
? is this oK – Perez