1

I have an ASP.NET WCF .svc interface which is accepting a POSTed form. I cannot control the POSTing client at all (which happens to be the IBM Lotus Forms Viewer application), but its behavior is that it POSTs itself to a URL of my choosing and the response is popped up in Internet Explorer as a locally served temporary file with an extension controlled by the mime-type.

I am new to WCF REST services, but I am having a hard time controlling the response, which keeps getting wrapped in XML tags. Is there a way to turn off all output wrapping and control exactly what is returned from the WCF operation?

I can point the form to something other than a WCF service (like an .aspx file), but I thought it would be useful at least to learn how the formatting is controlled before I made that decision.

[EDIT] For clarification, my current service interface prototype looks like this:

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/AF1067/SubmitForm",
     BodyStyle = WebMessageBodyStyle.Bare)]
public string AF1067_SubmitForm(System.IO.Stream fileContents) { ... }

[EDIT] User @Kon found this link which had the answer -- if I return a System.IO.Stream, the response will stop being wrapped.

Community
  • 1
  • 1
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
  • I have a feeling it comes wrapped in XML tags because the content type specified within the IBM app that the request originates from is incorrect. But it's hard to tell without seeing code. – Kon Jun 29 '11 at 13:14
  • @Kon: No, the request originates from the Viewer as a bare POST, which I can read just fine (see edit for details). Its my service response I need to fix. – Scott Stafford Jun 29 '11 at 13:18

1 Answers1

0

Continuing from our comments, I still think this may have something to do with the requestor's settings. Perhaps the bare POST which doesn't specify a content type setting defaults to the wrong one? Try to explicitly set it to "application/json" or "application/json; charset=utf-8" Just throwing ideas out there.

The other thing to make sure of is that your service method's ResponseFormat is set to JSON as well.

Btw, nice method name. ;)

Kon
  • 27,113
  • 11
  • 60
  • 86
  • But I don't want to exchange JSON, I want to return, say, "hello world." as the entire response. Does your comment still apply? – Scott Stafford Jun 29 '11 at 13:34
  • I believe your only options for response format are XML or JSON. And here's a good read on how to support both at the same time: http://stackoverflow.com/questions/5752975/wcf-service-method-to-return-json-or-soap – Kon Jun 29 '11 at 13:37
  • 1
    Though I just found this: http://stackoverflow.com/questions/992533/wcf-responseformat-for-webget It may lead you in the right direction. – Kon Jun 29 '11 at 13:43