Monthly Archives: December 2007

Microsoft Office Mobile 6.1: Upgrade

This update finally supports the new file formats of Office 2007 on your mobile device:

To allow Windows Mobile users to work with Office documents created in the Open XML formats, Microsoft has developed an upgrade for Word Mobile, Excel Mobile, and PowerPoint Mobile applications. This upgrade to the Office Mobile applications allows viewing and editing of Word documents and Excel workbooks and viewing of PowerPoint slideshows created by using Microsoft Office 2007.

Other improvements include:
• Enhanced viewing experience for charts in Excel Mobile.
• Ability to view SmartArt in PowerPoint Mobile.
• Ability to view and extract files from compressed (.zip) folders.

The update need approximately 7 Mb on your device. Therefore, I would recommend using a memory card for the installation.

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.