You Have Created a Service

Sometimes, simple things end up as epic battles. If you try to MSN Search and Google for the nasty “You have create a Service” page for IIS hosted WCF services, you will and up with a lot of pre-release information and noise in the search results. Actually, you might spend days in finding some relevant information.

You have created a service

Yesterday, I was finally pointed to the right place in the MSDN documentation where you can find this specific information:

<serviceDebug httpHelpPageEnabled="Boolean"
    httpHelpPageUrl="Uri"
    httpsHelpPageEnabled="Boolean"
    httpsHelpPageUrl="Uri"
    includeExceptionDetailInFaults="Boolean" />

With the serviceDebug tag it should be possible to get rid of the page. It is easy to find as long as you know you have to search for the term HTML help page.

WCF, .NET 3.5 and HTTP Request Content

The new Web Programming Model of WCF and the .NET Framework brings some very useful features such as the WebGet and the WebInvoke Attribute and the capability to deal directly with HTTP requests. But how do we access the HTTP request in these methods? Dealing with HTTP requests and responses using the System.Net namespace is quite straight forward. Therefore, we have a look in sending and receiving a simple HTTP request:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(myUrl);byte[] a_dataBytes = Encoding.UTF8.GetBytes(data);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = a_dataBytes.Length;

Stream requestStream = request.GetRequestStream();
requestStream.Write(a_dataBytes, 0, a_dataBytes.Length);
WebResponse response = request.GetResponse(); StreamReader responseReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); var content = responseReader.ReadToEnd();

Now we want to access the HTTP context within a operation with the following signature:

[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "{uri}")]
bool Put(string uri);

Accessing the context of the incoming request is straightforward using the WebOperationContext class.

IncomingWebRequestContext context =
WebOperationContext.Current.IncomingRequest;

var length = context.ContentLength;
var type = context.ContentType;
var headers = context.Headers;

Since the documentation does not provide many example code, and the ORCAS samples do not cover this yet, I had to figure out how to access the content of the incoming request. After spending hours on MSN Search, Google and the MSDN Library I finally tried out something. In some general examples, either a Message or a Stream is passed over as single parameter to the operation. Hence, I changed the contract as follows:

[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "{uri}")]
bool Put(string uri, Stream stream);

Reading the content then is easy:

var reader = new StreamReader(stream);string content = reader.ReadToEnd();

This solution however comes up with one major drawback: If you try to access your foo.svc via browser you will end up some error telling you “For request in operation Post to be a stream the operation must have a single parameter whose type is Stream.”. Also calling foo.svc?wsdl will end up in some exception in the WSDL export extension.

WRT54GSV4 Wireless Bridge

After switching from WEP to WPA2, of course I had to update several XP and Vista machines. However, the 360 made most trouble since I used a D-Link 700AP before which was configured as a wireless bridge. Since I run a Linksys WRT54GS as gateway, it seemed to be the easiest way to get a second device of the same kind to be set up as wireless bridge being flashed with an alternative firmware. However, I realized that there is a endless number of devices in this series. After getting the device, I had to figure out, the new device is version 7. Due to an change in the manufacturer firmware, the ROM size of the device was continuously reduced. At this time I thought about the fact, getting a WRT54G (which is the old hardware factor and Linux based) might have been the better choice. Now I simply replaced the existing device with version 4 with the new one. and the old one providing 4 MB of RAM became the wireless gateway.

There are a couple of alternative firmware projects for the WRT54GS. After reading though a couple of posts in various forums, it seemed that OpenWrt is the best choice. In addition, X-Wrt seemed to be suitable for easy setup. During the setup of OpenWrt, I encountered several problems ending up in my router being bricked. So I had to recover the device using TFTP and the original firmware.

After several failures and digging a bit more I found more and much better documentation on DD-WRT including documentation for setting up wireless bridges. While v23 does only support WPA2-mixed mode, I switched over to v24 RC4 which finally supports WAP2 Personal.

How to listen iPod while charging on Vista

While charging an iPod on a Windows Vista system without having iTunes installed, you might face the issue that the iPod is not willing to play any music as long as it is charging. Therefore, simply choose Safely Remove Hardware from the Vista task tray.

Safely Remove Hardware

There you select Generic volume and click Stop. In the second dialog do the same, select Generic volume and click Stop.

Stop a Hardware device

After a few seconds your iPod will re-start and awaiting your commands while it is still charging.