kernology - where laurie and learning meet
  • Home
  • Blog
  • Pictures
    • Art & Craft >
      • Temari
      • Yubinuki
      • Quilting
      • Weaving
      • Lapidary Work
      • Metal Work 2010
      • Metal Work 2009
      • Classes - 2010
      • Classes - 2009
    • Boots
    • Canyon Lake Gorge
    • Views of Texas
    • Views of Scotland
    • Travel >
      • Bunny Bravehart Road Trips
      • Scotland 2012
      • Maine 2011
      • New Mexico 2010
      • Scotland 2008
  • Oh, the places you will go!
  • Contact Laurie

It's a cold day in Scotland

1/18/2013

 
It is not "Winter is coming" as they say in Game of Thrones, but IT IS HERE. Actually it is there, in Scotland and Elisa has sent some pictures from her yard.
Picture
Dec 28, 2012. The pheasant is stocking up while it can.
Picture
Jan 14, 2013 Snow has arrived and coated the Cotoneaster berries
Picture
Jan 14, 2013 Snow has arrived and coated the the fir tree as well
Picture

Slaying the Beast Known As...

1/3/2013

 
Over the past two weeks, at work, I have been beating on a problem.  I am glad to report that it has been solved but it was not fun. There were days that I did nothing but Google and change my code but nothing would work and because what I was working on can be done so many different ways, there was not a single Google result that directly addressed my situation. Which is why I am posting this now. I hope that this will help someone else.

If you write code in Visual Studio, .net and you write services - read on. If you have no idea what this means, I suggest you read now because if you continue you might get a headache.

The beast that I am referring to is WCF. [Windows Communications Foundation]

Writing a WCF Service can be daunting if you have never written a Web Service before and trust me it can be daunting even if you have written an old style Web Service but have never touched WCF.

But configuring the Service and the client that uses it can make a seasoned developer curl up in a ball, under their desk, and whimper if not make them out right CRY.

This post won't go into how to write a WCF Service.

This post won't go into how to write a Client to consume the Service either.

What it will do is detail the problems it has taken over a week to sort out on the configuration of the service host and the client when using basicHttpBinding (again, if you don't know what that is I suggest you run, run fast and run NOW!). Yes there are other binding options but this is the one I was dealing with.

Here is the set up.

I have a WCF service.  Right now it runs on a production machine using HTTP (that's an internet protocol for those of you who did not run away) We will be eventually using HTTPS with Certificates but for now, we want to use HTTPS with OUT cert's.

I need to test this on my local development machine. Yes, I have a cert installed in IIS. No, this post will not tell  you how to create a cert or how to install one - that is what Google is for.

For calling your service over ONLY http this what should be in your config files. First up is the web.config which is for the Service Host and after that is the app.config which is for the client.

Note: all  the other settings have been removed for brevity.
Picture
Picture
If you want to call your service over HTTPS with NO certificates, each file would look like the following. In the Web.confg you change the security mode to transport and then add the transport client credential type. Because we are not using certs, the type is NONE.  And don't forget to change the address URL to have the ‘s’ in the HTTP as shown in the next two screen shots.
Picture
Picture
But wait, there is one more thing that must be verified and that is the SSL settings in IIS. Your certs should be installed at this point but NOT turned on.
Picture
But what if you have different clients and one will call over https and one will call over http AT ANY TIME. It would be great if you could have the configuration files set up so you could call either protocol. 

The app.config can have two client enpoints and bindings and we will come back to that, but the web.config can only have one named service per actual service in the service host.  

I made the mistake of thinking that having two endpoints and two bindings would be the way to set up the configuration, so I set up my web.config to look like this…
Picture
Picture
Trust me, this does not work. The issue is with the web.config and how it is read by the system.

Adding a second endpoint and a second binding for the end point so one points at the http address and the other points at the https end point results in all sorts of errors such as:
  • Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http]
  • WCF endpoint could not be found for HTTPS
  • There was no endpoint listening at http://localhost /Service.svc that could accept the message.
  • There is no compatible TransportManager found for URI. This may because that you have used an absolute address which points outside of the virtual application

And the documentation is not that great on how accomplish this scenario. But this last error gave us a hint and that is the word  “VIRTUAL”

Here is what the two configuration files should look like and afterwards I will explain why.
Picture
Picture
Why does this work? Originally we configured the address of our service explicitly in the address attribute of our service's endpoints. That works when calling only http or only https. When you want both, there is a conflict because the service really does not know what end point to serve up to the client. I know, it seems like it should because we have explicitly specified the URL to use in the client; it is the service that is getting confused.   We have been using RELATIVE ADDRESSES.
If you look at the addresses specified in the client configurations, we have added what appears to be a subfolder to the addresses used in the client endpoints. These are not subfolders of the service. They are the NAMES of the service ENDPOINTS. And in the host node, we have two base addresses one for http and one for https.  THIS USES VIRTUAL ADDRESSES!   Because the client specifies which end point of the service to use, the Service uses what is called *Discovery mode* and it works out based upon the behaviors and bindings what security mode to use and thus it the url to use.

No, I will know go into the mechanics of what is really going on under the hood – even my eyes will roll into the back of my head if I did that.

I just hope that this will help someone else and save them the 3 days it took me to figure it out.

And a big thank you goes out to El Jeffie who also worked on this and found the final solution.

    RSS Feed

    About Laurie

    Laurie lives in central Texas with the memory of Erich, a.k.a. "the shop elf", who was her hubby of 35+ years and Cowboy Boots, the cat; her metals studio including 100+ hammers and 300+ chasing tools; her sewing studio which has a sewing machine, a closet filled with fabric, hundreds of skeins of embroidery floss and perle cotton, silk and other materials, and Mrs. King the dress dummy; one weaving loom, assorted knitting needles, tubs of yarn; assorted art supplies of pencils, colored pencils, water color pencils, water color paints, acrylic paints, markers, and pads of paper; lots of books; plus a plethora of geeky tech gadgets, computers, and more.

    Archives

    May 2025
    March 2025
    February 2025
    January 2025
    December 2024
    November 2024
    September 2024
    August 2024
    July 2024
    May 2024
    April 2024
    March 2024
    January 2024
    December 2023
    November 2023
    October 2023
    September 2023
    August 2023
    July 2023
    June 2023
    May 2023
    April 2023
    March 2023
    February 2023
    January 2023
    December 2022
    November 2022
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    June 2020
    May 2020
    April 2020
    March 2020
    February 2020
    January 2020
    December 2019
    November 2019
    September 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    November 2017
    October 2017
    September 2017
    August 2017
    June 2017
    May 2017
    April 2017
    March 2017
    February 2017
    October 2016
    September 2016
    August 2016
    June 2016
    May 2016
    April 2016
    February 2016
    January 2016
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014
    May 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    February 2013
    January 2013
    December 2012
    November 2012
    October 2012
    September 2012
    August 2012
    July 2012
    June 2012
    May 2012
    April 2012
    March 2012
    February 2012
    January 2012
    December 2011
    November 2011
    October 2011
    September 2011
    August 2011
    July 2011
    June 2011
    May 2011
    April 2011
    March 2011
    January 2011
    December 2010
    November 2010
    August 2010
    July 2010
    June 2010
    May 2010
    April 2010
    March 2010
    February 2010
    January 2010
    December 2009
    August 2009

    Categories

    All
    42
    Android
    Bfa
    Boots
    Bunny Bravehart
    Codesmith
    Comic-Con
    Covid
    Day Job
    Family
    Fencing
    Fiber
    Gorge
    Health
    Hike
    Jewelry
    Knitting
    Laurie
    Metals
    Minecraft
    Pandemic
    Photography
    Quilting
    Retirement
    Road Trip
    Scotland
    Sources
    Spinning
    Temari
    Texas
    The Big Walk
    Weaving
    Web
    Yubinuki

Kernology, Kernology.com, Laurie Jane Kern © 1998 - 2020 | All Rights Reserved