The provided URI scheme 'https' is invalid; expected 'http'.

Topics: Web Api
May 2, 2011 at 6:00 PM

After upgrading to the latest preview 4 we now get the error:

The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress

We get this even though the request IS http. So it's telling us it "expected http" for the http request? I've looked through other threads that detail the setup for https but we aren't using https.

 

Any ideas?

 

 

The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress

May 3, 2011 at 4:19 AM

Thanks David Peden for the tip to remove the IIS binding for https. Very unexpected behavior but gets us going until a fix is presented.

May 12, 2011 at 6:48 AM

I'm a noob so my forgive my stupidity - how does one remove the IIS binding for HTTPS and/or add binding for HTTP + HTTPS?

May 12, 2011 at 9:52 PM
RogerWilco wrote:

I'm a noob so my forgive my stupidity - how does one remove the IIS binding for HTTPS and/or add binding for HTTP + HTTPS?


Depends on what version of IIS your are running.  I'm running 7.5 and don't have easy access to anything earlier so this reply may not be useful to you but assuming you are using 7.5....

1. Launch IIS Manager

2. Expand the folders to the web site node (usually 'Default Web Site')

3. On the right hand side under 'Actions', click on 'Bindings...'

4. Select the binding that you would like to remove and click 'Remove'

May 12, 2011 at 11:34 PM

Thanks - that worked.

May 13, 2011 at 12:08 AM
RogerWilco wrote:

Thanks - that worked.


Just remember that this is a workaround, not a solution.

Glenn, can you tell us what the right way is to resolve this issue?  Especially if you're operating in a hosted environment where you don't have this level of control?

Pretty please?  :P

Coordinator
May 13, 2011 at 12:17 AM

Can you guys do me a favor. Can you test out hosting a service without the changes by using HttpServiceHost / HttpServiceHostFactory instead of the HttpConfigurableServiceHost. This means instead of using MapServiceRoute, add a ServiceRoute passing an HttpServiceHostFactory as a param.

Thanks

Glenn

Coordinator
May 13, 2011 at 12:18 AM

By without the changes I mean without using the workaround.

May 13, 2011 at 4:06 AM
gblock wrote:

Can you guys do me a favor. Can you test out hosting a service without the changes by using HttpServiceHost / HttpServiceHostFactory instead of the HttpConfigurableServiceHost. This means instead of using MapServiceRoute, add a ServiceRoute passing an HttpServiceHostFactory as a param.

Thanks

Glenn


Hey Glenn,

I'll get it tested by this weekend.  Thanks for the response.

May 14, 2011 at 10:05 PM

Negatory. Passing an instance of HttpServiceHostFactory à la:

RouteTable.Routes.Add(new ServiceRoute("someroute", new HttpServiceHostFactory(), typeof(SomeResourceType)));

doesn't work, nor does:

RouteTable.Routes.MapServiceRoute<SomeResourceType,HttpServiceHostFactory>("someroute");


Coordinator
May 15, 2011 at 2:05 AM

Thanks cv55555 for the effort.

Glad I don't have to whip myself for introducing a bug in HttpConfigurableServiceHost :-) We'll look into it.

May 16, 2011 at 4:59 PM

I haven't uploaded any of my projects to our servers yet so excuse my dumb question...but....
Does this mean that we can use a project that listens on 443?  Does Https just not work?  

If this is the case, does that mean that we should stop using the Web API's and start concentrating on MVC?  While I love the all the hooks and pipeline that this framework provides, I think we can do 80% of it through MVC, and the API we are developing now must be Https.

May 16, 2011 at 9:41 PM
INeedADip wrote:

I haven't uploaded any of my projects to our servers yet so excuse my dumb question...but....
Does this mean that we can use a project that listens on 443?  Does Https just not work?  

If this is the case, does that mean that we should stop using the Web API's and start concentrating on MVC?  While I love the all the hooks and pipeline that this framework provides, I think we can do 80% of it through MVC, and the API we are developing now must be Https.


It just means that you have to remove the HTTPS binding on your website until they fix it binaries. Removing the HTTPS binding is just a workaround for now.

May 16, 2011 at 10:27 PM
Not to put unreasonable pressure on the team, but is there at least a vague ETA for the fix? This is quite key :(
May 16, 2011 at 10:28 PM

Got it...

That is too bad.  I was digging the framework and all the low level access to the Http messages/pipeline.  I guess it's back to ASP.net MVC for me.
Hopefully thing mature more the next time we release a new version.

Regardless, great work so far.

May 16, 2011 at 11:16 PM
Edited May 16, 2011 at 11:18 PM
gblock wrote:

Thanks cv55555 for the effort.

Glad I don't have to whip myself for introducing a bug in HttpConfigurableServiceHost :-) We'll look into it.

Ditto.  I was unable to make good on my claim this weekend and was going to do it tonight.  Thanks for getting the testing done!

cb55555 wrote:

It just means that you have to remove the HTTPS binding on your website until they fix it binaries. Removing the HTTPS binding is just a workaround for now.

 Just so everyone's clear, you can't have both bindings running simultaneously. It's not that HTTPS doesn't work. If you are working in an environment where everything is HTTPS, you can remove the HTTP binding and be functional. Whether or not this is recommended is up to you and your specific situation.

May 16, 2011 at 11:32 PM
INeedADip wrote:

Got it...

That is too bad.  I was digging the framework and all the low level access to the Http messages/pipeline.  I guess it's back to ASP.net MVC for me.
Hopefully thing mature more the next time we release a new version.

Regardless, great work so far.


You can still use:

using System.ServiceModel.Activation;
using Microsoft.ServiceModel.Activation;
...
RouteTable.Routes.Add(new ServiceRoute("someroute", new WebServiceHostFactory3(), typeof(SomeResourceType)));

The only difference is that your endpoints have to be weakly-typed:

        //Weak typing using RouteTable.Routes.Add(new ServiceRoute("someroute", new WebServiceHostFactory3(), typeof(SomeResourceType)));
        [WebInvoke(UriTemplate = "Method1", Method = "POST")]
        public JsonValue Method1(JsonValue somejson)
        {
           ...
        }

        //Strong typing using RouteTable.Routes.MapServiceRoute<SomeResourceType>("someroute")
        //Doesn't work with WebServiceHostFactory3()
        [WebInvoke(UriTemplate = "Method2", Method = "POST")]
        public SomeObjectType Method2(SomeObjectType someobj)
        {
           ...
        }
May 16, 2011 at 11:36 PM

Oh, if you use WebServiceHostFactory3(), your resource class needs to have this attribute:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

That bit me in the ass. And it was quite painful! :)

Coordinator
May 17, 2011 at 12:58 AM

INeedADip

You are saying not having HTTPS is the blocker? My understanding is we do support HTTPS now if you are running on IIS. The issues I think folks are seeing here looks like deploying to IIS WITHOUT using HTTPS.

For all on this thread, this will be taken care of. We need to repro so we can see what the issue is. It is not going unnoticed.

Thanks!

Glenn

May 17, 2011 at 1:09 AM

Awesome, Https is a requirement.  We can do without the Http for now.  I guess we'll complete the prototype and push it up to our servers for some tests.

Again, excellent work thus far!

May 17, 2011 at 2:23 AM
gblock wrote:

INeedADip

You are saying not having HTTPS is the blocker? My understanding is we do support HTTPS now if you are running on IIS. The issues I think folks are seeing here looks like deploying to IIS WITHOUT using HTTPS.

For all on this thread, this will be taken care of. We need to repro so we can see what the issue is. It is not going unnoticed.

Thanks!

Glenn


Hey Glenn, I ran into this problem when hosting with IIS, not self-hosting.  After observing the errors when forcing SSL and not, it became clear to me that no matter what scheme I used, I got the opposite problem.  It occurred to me that removing one of the bindings from IIS might "resolve" the issue and it did.  All of my coding/testing has been against IIS 7.5 and Azure.

May 17, 2011 at 9:46 PM

I got both schemes working when hosting on both IIS and Self-Hosted by following a piece of advice (from Glenn I believe) in a different thread.

You have to override the HttpConfigurableServiceHostFactory, and then override the CreateServiceHost method.

Here's my code:

        public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
        {
            var host = base.CreateServiceHost(constructorString, baseAddresses);
            
            foreach (var httpBinding in from serviceEndpoint in host.Description.Endpoints
                                        where serviceEndpoint.ListenUri.Scheme == "https"
                                        select (HttpBinding) serviceEndpoint.Binding)
            {
                httpBinding.Security.Mode = HttpBindingSecurityMode.Transport;
            }
            
            return host;
        }

Mario
Coordinator
May 18, 2011 at 12:34 AM

Thanks for sending this. Yes I did suggest you need to set that endpoint and made it easier to do that in the config. That is a good workaround in the current bits, blog post coming!

Glenn

May 18, 2011 at 3:05 AM
gblock wrote:

Thanks for sending this. Yes I did suggest you need to set that endpoint and made it easier to do that in the config. That is a good workaround in the current bits, blog post coming!

Glenn


Hey Glenn,

I will need to do some more testing but I did use your forked bits and that's when I ran into trouble.  Maybe I did something wrong and will need to confirm.  Anyway, looking forward to your post.  Thanks for keeping us up to date.

Jun 28, 2011 at 6:43 PM

I just started with this library yesterday and ran into this issue with my MVC3 app running in the Azure Dev Fabric.  Any update on this issue? 

I have tried the suggestion of overriding CreateServiceHost with no success.  I then tried to rebuild the assembly with the changes in HttpConfigurableServiceHostFactory with no success. 

Nov 6, 2011 at 1:06 AM

Would you mind posting a complete example of how to use SSL (only) for the current WebAPI 5 release?