Questions tagged [weboperationcontext]

The WebOperationContext can be used in WCF services to access properties of web requests and responses.

The WebOperationContext can be used in WCF services to access properties of web requests and responses. It will only be useful for specific bindings.

References

21 questions
34
votes
3 answers

What is the WCF equivalent of HttpContext.Current.Request.RawUrl?

I've got some RESTful services running in a pure WCF context (i.e. ASP.NET compatibility is not enabled, and thus there is no HttpContext.Current object available). The URLs to the services are rewritten at the start of the request using an…
Greg Beech
  • 122,952
  • 42
  • 199
  • 241
8
votes
4 answers

WCF 4 REST service can't return a StatusDescription, only StatusCode

I'm currently migrating my WCF RESTful service from .NET 3.5 (Starter Kit) to .NET 4. I started my project using a WCF Rest service template from Visual Studio 2010. I had to figure out how to keep my authorization scheme (formely done with…
8
votes
5 answers

How to mock WebOperationContext for unit testing?

I am trying to get a unit test(more of an integration test) written for the GetAwesomeResultsAsXml() for the following WCF Rest Service. How do I deal with the WebOperationContext mocking aspect? What would be the best approach? public class…
GilliVilla
  • 4,596
  • 10
  • 50
  • 85
6
votes
1 answer

Testing WCF methods with Nunit but WebOperationContext is null

How do you get around the WebOperationContext being null in a WCF service method when testing the method using NUnit I have a unit test project using NUnit to test data returned by a WCF Method: public class SampleService { public XmlDocument…
Max Alexander
  • 5,029
  • 6
  • 35
  • 48
4
votes
2 answers

Performing CreateTextResponse(...) in mocking WebOperationContext as in WebOperationContext

I'm mocking the WebOperationContext class over wrapper for unit testing (using Moq). But I need to execute CreateTextResponse(...) method from WebOperationContext class in my mocked context for Message generation. Could you please give me any…
kazarindn
  • 169
  • 8
3
votes
0 answers

Mocking WebOperationContext.IncomingRequest

I need to mock the WebOperationContext and specifically the IncomingRequest with a header that assigns the Accept value, as to test that the value is being read properly and the OutgoingReponse.ContentType matches that the desired format. I'm using…
bryan
  • 1,001
  • 2
  • 16
  • 34
3
votes
1 answer

WebOperationContext.Current.OutgoingResponse.StatusDescription is ignored

Value that I set on server side for WebOperationContext.Current.OutgoingResponse.StatusDescription property is ignored. Client side gets a default message, for example Not Found for 404 code, OK for 200.
brain_pusher
  • 1,427
  • 3
  • 20
  • 31
3
votes
0 answers

Doesn't exist: WebOperationContext.Current.OutgoingRequest.Headers.OutgoingResponse.Headers.Add

I am trying to use the following command in a silverlight application "WebOperationContext.Current.OutgoingRequest.Headers.OutgoingResponse.Headers.Add". However it doesnt appear to exist. I know it does exist because it is on the microsoft…
CodeGuyRoss
  • 716
  • 10
  • 22
2
votes
2 answers

Does a stream close when you return it in a WebOperationContext?

I'm returning some images as a stream as part of a WebOperationContext.Current.CreateStreamResponse() I was wondering if the framework handles the closing of this stream after it gets returned. Or if there was something that you have to do as part…
JSmyth
  • 10,945
  • 3
  • 21
  • 18
2
votes
0 answers

WebOperationContext Object reference not set to an instance of an object

When I try to use WebOperationContext.Current in a WCF project, the Current is null. Below is the example. Could anyone please shed a light on it? WebForm - default.aspx: ServiceClient sc = new ServiceClient(); Response.Write(sc.DoWork(1) +…
user483320
  • 21
  • 3
2
votes
1 answer

WebOperationContext.Current in WCF service null

I have a WCF service with the service file as - Serivce.svc Here I can read incoming headers using the WebOperationContext.Current The code from the Service file access a data access utility layer which makes other calls; I need to to do some work…
user1542794
  • 137
  • 1
  • 12
1
vote
1 answer

Mocking WebOperationContext

I'm using the WCFMock to mock the WebOperationContext in my web service. The only usage is to add a custom HTTP header to the WebOperationContext.Current.OutgoingResponse.Headers collection. I'm unable to verify this using Moq. What I've already…
Krishter
  • 469
  • 6
  • 22
1
vote
1 answer

is WebOperationContext available in a static function?

I have a RESTful WCF service that have a service method say BeginX() Inside BeginX, I call my static Validate function in a static helper class. Inside the static Validate method, can I call WebOperationContext.Current.OutgoingResponse.StatusCode =…
kosh
  • 531
  • 1
  • 7
  • 21
1
vote
1 answer

WCF add query parameter not expected in signature

I have a contract used in a WCF POST. During the call, I need to add an extra parameter that I cannot add in the signature, because I get disambiguation issues. Contract: [OperationContract] [WebInvoke(UriTemplate = "", Method = "POST")] …
Lorena Sfăt
  • 185
  • 5
  • 16
1
vote
3 answers

Read request content in JSON form from OperationContext in C#

I have created WCF RESTful service as below: [OperationContract] [WebInvoke(Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/Customer/{customerID}/profile")] string…
Pratik Soni
  • 942
  • 4
  • 14
  • 37
1
2