Hey Jim,
Sorry for the extremely delayed response! I became very busy over the past few months and had to put down my Rest In Practice book.
But I picked it back up this week. And I figured out my issue :) (also, sorry for the empty repo, I thought I pushed my code there but I guess I hadn't).
Ch. 4 .NET overview:
The .NET package comes with 3 solutions: a client (using System.Net to make web requests), and 2 different solutions that implement the "server" in different ways.
HttpListenerOrderingService also uses System.Net to listen for any incoming web requests. It's very dumb. It shaves off the last segment of the URI (presumably your orderID) and computes it's logic using the homemade OrderDatabase.
WCFOrderingService uses,well, WCF to host the service. So we're using the System.ServiceModel assemblies here to define service/operation contracts.
Firstly, in the Program.cs for your client you'll want to make the following 2 changes in order to make a valid request:
1. remove the "." character right after the 1 in "127.0.0.1.", that is technically an invalid URI.
2. you need to add the following line of code after creating your HttpWebRequest object:
request.SendChunked = true
These are the changes I needed to make in order to get it working for me. Otherwise you'll continue to receive the error message I stated originally.
Secondly, you will need to decide on what solution you will use for your service. They designed the client so that it could use either service implementation, which kinda made it confusing for me without any documentation on it. :/
Try running WCFOrderingService (build, run without debugging). You should get a notification stating the VS dev server is running. Then, in your browser you can navigate to http://localhost:8080/OrderingService.svc/orders/1234 to verify the service is running (you will see an XML representation of the order). Then, if you run your client... boom! Nothing happens, but no exceptions should be thrown either. I debugged the WCF service by attaching it to the server and verified my client made the PUT request validly. It did... kinda. It's supposed to send an Order object (according to the operation contract) but we are only sending an XML-representation stream of the order. Anyway, the basics of the client PUT to server works, so I was happy.
Try running the HttpListener service. It will spawn a command prompt to notify you of what's going on. As you can see, nothing is defined if a PUT request is made (although they defined GET and DELETE??). So you should see your server spit out the web request method (i.e. PUT) as well as the orderID you send over (1234).
I'm guessing the authors of this code left A LOT out for us to implement ourselves? I'll be working on this code for a little while longer, because I want to get the PUT to work for both servers, then perhaps make the GET DELETE and POST methods to work. Feel free to email me with any questions on this chapter of code.
Thanks,
Ryan