HTTPS support

Topics: Web Api
Dec 30, 2010 at 1:09 AM

Hi -

We have an existing WCF service over HTTPS that I am looking into moving to REST. You say that you do not support this - would this block me from using WCF HTTP or does this just mean that you do not have the infrastructure but I could use our own existing support for HTTPS?

Dee

Coordinator
Dec 30, 2010 at 1:28 AM

We do/will support HTTPs. I am not sure however it works with the current bits.

Glenn

Dec 30, 2010 at 2:03 AM

Sorry - I am confused. You mean REST will work with HTTPS but you are just not sure that it will work with this framework? Do you know when you plans to support this?

 

Dee

Coordinator
Dec 30, 2010 at 2:19 AM
Edited Dec 30, 2010 at 2:20 AM

WCF Web Apis absolutely will support HTTPs. The current codeplex release however is a very early preview and HTTPs many not work properly. Within the next month  or so we should have another drop that will support it.

In the thread above you mentioned "You say that you do not support this". What exactly are you referring to? HTTPS in general, or taking an existing WCF WEB HTTP service and simply moving over to the new release?

Thanks
Glenn

Dec 30, 2010 at 2:35 AM

From your downloads page below - I was trying to understand what you mean by the highlighted statement.

Known Issues with WCF HTTP

  • ContactManager sample does not work properly on Firefox
  • Not tested with MVC3
  • HTTPS and self-hosting does not work
  • Automatic help pages do not work
  • Request uris need to have a slash after the resource i.e. /customer/1 and /customers/ are valid but /customers is not.

Dee

Dec 30, 2010 at 2:37 AM

Off-topic but any resources to do the conversion? Discussions/pointers, etc ?

Dee

Coordinator
Dec 30, 2010 at 3:08 AM
Edited Dec 30, 2010 at 3:15 AM

The point below is about using HTTPs in a self-hosted scenario. That is not working in the current bits, but will be fixed soon. Is that your issue? As far as converting existing services, there's nothing definitive yet, though we are planning on a sample and more guidance. The project is still in the very early days. In general the main concerns in terms of migrating are the following:

1. Usage of WebOperationContext, something that today folks often have to rely on if they want to accesss http headers, or set the status code. In the new bits we have a nicer API for directly accessing HTTP headers and such that replaces WebOperationContext. The new api is a set of strongly typed message classes HttpRequestMessage and HttpResponseMessage which wrap the underlying raw HTTP request/response. If you look in our ContactManager sample you will see how it uses the ResponseMessage to set the status code for a missing resource.

To use them you simply add an HttpRequestMessage or HttpResponseMessage paramter for example:

[ServiceContract]
public class CustomerResource {
  [WebGet("Customer/{customerID}")]
  public Customer Get(HttpRequestMessage request, HttpResponseMessage response, int customerID}
  {
    ...
  }
}

2. Streaming support has changed. In WCF HTTP 4.0, you use a stream/message on the signature of the operation to support accessing the raw stream. In the new model, you no longer user stream and message on the signature. Instead to support streaming, you use the content property of HttpRequestMessage / HttpResponseMessage. The property is of type HttpContent and provides methods for getting access to the stream either for reading, or for writing. In the read case there is a method which returns the stream. For writing you use the HttpContent.Create method and pass in either a stream, or an Action<stream> to create an HttpContent instance. You then set this to the content property i.e. below I am passing an Action<stream>

[ServiceContract]
public class StreamingResource {
  public void Get(HttpResponseMessage response) {
    var content = HttpContent.Create(
    {s=>... //write to the stream});
    response.Content = content;
  }
} 

Note: In the next drop you will see that this syntax is changing. Instead of using static factory methods on HttpContent you will create a StreamContent object.

3. Wrapped bodies are not currently supported. In WCF 4.0 you can set your operation to have a WrappedBodyStyle. This allows you to have multiple parameters on the operation which are mapped from the body. Our current plans are to support this.

Item 1 is probalby the one that will affect most people trying to migrate. The changes we are introducing are deliberate in order to bring the platform forward with more first class HTTP support. WebOperationContext stands in the way of offering the best experience which is why we have chosen this path. The plus side of the new functionality is offer a whole new set of capabilities that are more suitable for fully leveraging HTTP such as giving you complete flexibility of formats i.e. xml, json, atom, better support for browser clients using JQuery, as well as much richer support for processing the request/response outside of the context of the operation using our new processor pipeline and forthcoming http channels.

In terms of more overall guidance on our new efforts, check these two links:

Hope this helps and thanks for your patience.

Glenn

Dec 30, 2010 at 5:31 PM

"The point below is about using HTTPs in a self-hosted scenario. That is not working in the current bits, but will be fixed soon. Is that your issue? As far as converting existing services, there's nothing definitive yet, though we are planning on a sample and more guidance. The project is still in the very early days."

So would you say that for a product with a planned launch date of early February that it'd be a risky bet to use these bits, particularly if said product required https to launch?  I must say that my experience with these bits so far has been remarkably more pleasant than all my other WCF experiences..

Dec 30, 2010 at 11:05 PM

Hi,

Please see: http://wcf.codeplex.com/Thread/View.aspx?ThreadId=233576

With some minor changes on the current version it is possible to have HTTPS with self-hosting.

Regards

Pedro Félix

 

 

Coordinator
Dec 31, 2010 at 3:50 AM

One of my guys just checked and it looks like we do the right thing in the bits we have checked in. We're planning a drop next week, but it doesn't have all our latest bits. I may see if I can get this patch in though.

Thanks
Glenn