Two WCF Stumbles

Posted in .NET, Coding, WCF, Work by Will on March 16, 2008.

Here’s two things that caused me a bit of pain when working with WCF. Hopefully these pointers should help you get back to more productive things.

No Output when returning Serialized / Serialised objects.

I had been working on adding a significant number of methods and properties to a series of classes, and when I went to test the service I got literally no output.

Debug points indicated that all properties were there, and valid - but still WCF wasn’t returning anything. There was no exceptions  being returned to the client.

The best tool for debugging these sorts of solutions is to first of all enable Tracing and MessageLogging.  This is done via the WCF Service Configuration Editor, on the Diagnostics tab. 

Once you’ve done that, and re-run the projects - you can open up Service Trace Viewer.  For me under Visual Studio 2008, this was under Microsoft Windows SDK v6.0A > Tools.

image

This tool then lets you open up the trace log generated in your solution directory, and see all the activity that’s been happening.

debugging-wcf-services

From here, it was just a matter of scrolling down to the activity entry that had the yellow hilighting (indicating a warning), selecting it - then clicking on the Errors.

For me, the first time this happened to me, it was because I had stuffed up the DataMember Name values. It has also occurred for other reasons, such as a property not being populated, when I had specified that it was both required, and also that it could not emit a default value.

Can’t get mex to work

No, this isn’t a misguided racial slur. I was having issues setting up the mexHttpBinding on an ASP.NET AJAX WCF Service.

The solutions all point towards the same thing, that you need to set up an endpoint, and set the contract to IMetaDataExchange, then set the behaviour to have <serviceMetadata />. Except that it just wouldn’t let me add that property to my endpoint behaviour, and whenever I changed it to a service behaviour it would then not allow me  to set the other properties I needed for that.

Well, perhaps I’m particularly slow - but hopefully this pointer will help someone else.

1: Create a NEW service behaviour:

<serviceBehaviors>
  <behavior name="MyServiceBehavior">
    <serviceMetadata
      httpGetEnabled="true"/>
    <serviceDebug
     includeExceptionDetailInFaults="true"
     />
  </behavior></serviceBehaviors>

2: Add a new endpoint to your  existing service

<endpoint
   address="mex"
   binding="mexHttpBinding"
   bindingConfiguration=""
   contract="IMetadataExchange" />

3: Add the behaviorConfiguration you added in Step 1 to the Service (NOT the endpoint).

<service
  behaviorConfiguration=”MyServiceBehavior”
  name=”MyProject.MyService”>

I kept trying to add it to the endpoint, and failing miserably. So much time spent back-and-forth on this!

 

That’s it for this instalment of “WCF is great, but I wish the config was a bit easier to understand”. Stay tuned for more exciting episodes!

WCF Service Giving Blank or No Response

Posted in .NET, Coding, IT, LINQ, WCF, Work by Will on March 13, 2008.

Today I spent about half an hour banging my head against this problem:
Whenever I would try and return a business object, I’d simply get no response from my WCF Service. Litterally nothing.

The problem turned out to be that I had accidentally specified the DataMember Name of a property in a sub object twice.

So, I had my broken class set up like:


[DataContract(Name = "MyClass", Namespace = "Example")]
public partial class MyClass
{
[DataMember(Name = "property1")] public int Property1 { get; set; }
[DataMember(Name = "property1")] public string Property2{ get; set; }
}

An instance of this class was used as a property in another object, which was being returned from WCF.

.NET didn’t throw any sort of error unless I tried to return just “MyClass”.

Sure, it was my fault, but if you have a complex data structure, this could get awefully difficult to find without some sort of message from WCF.

Yes, this is part of that ultra nifty WCF JSON .NET 3.5 Flex project at work. :)

LINQ to SQL, WCF, JSON and Flex. Oh My.

Posted in .NET, Coding, IT, LINQ, WCF, Work by Will on March 8, 2008.

(A note to readers: This is all pure geek/coder content - Please skip this if nothing in the subject line makes sense)

I started on a new project at work for a client a bit over a week ago, by virtue of the requirements, we decided to investigate the use of new version of Microsoft’s  .NET Framework, Version 3.5, for all of the server-side services.

Microsoft have been quite strongly pushing the benefits of the new features of .NET 3.5. There’s been a few key features which are particularly interesting, and if all goes according to the marketing hype, should end up saving a huge amount of time and effort, whilst ensuring that we use well known and standardised interfaces.

What features?

Windows Communications Foundation (WCF) is particularly interesting because it promises to let you (mostly) remove the whole ‘how’ and ‘where’ portion of communications between tiers, and let you focus on the ‘what’ and ‘when’.

In essence, WCF should let me state that I want to create (say) a Web Service, that accepts information in format X, and outputs responses in some other format. It doesn’t have to be a Web Service either, it could be a Peer to Peer network speaking in straight binary streams.

For this project the client-functionality is all in Flex, so we need to ensure that the Flex guys can quickly decode all the responses and turn them into Action Script objects. Through a bit of experimenting and application prior experience - Web Services speaking JSON appeared to be the easiest and most light weight method of doing this.

Language Integrated Queries (LINQ) is another particularly interesting technology, particularly because it lets me focus on what I want to do with the data I have, rather than spending time transforming it from the Database tables, rows, and procedures, into .NET objects and methods.

There are a number of implementations of LINQ, which enables you to query a variety of sources - the one that I’m most likely to use is LINQ to SQL (talking to SQL Server). Regardless of what I’m accessing however, the syntax is identical - again, removing the need to modify my code if I need to query an XML file, Oracle or MySQL Database, or even native .NET objects.

You can probably see a common theme here - WCF lets me focus on communication with the outside world without needing to write that interface or conversion functionality, and LINQ lets me access and manipulate data, without needing to write that interface either.

So, it’s all plug and play?

Well, that depends entirely on what you’re doing with your data. If you’ve got something like a CRM application where the client is responsible for managing (most of) the data, then yes it can quite possibly be almost plug and play if you’re going with a “CRUD” interface.

If your data structure is more complex, then you need to determine exactly where the split is. In this specific project, I’m presenting an abstracted view of the data that the client needs, and doing all of the business logic to manage data management in the SQL and Web Services Layer.

So far, the whole WCF and LINQ combination looks good. I’m hoping to post some more detailed posts later on.

Further Reading

I highly recommend Scott Guthrie’s LINQ to SQL series of posts. Start with Part 1: Introduction to LINQ to SQL

These resources have also been of a great help in getting my head around the whole LINQ thing:

Good News, everybody!

Posted in Work by Will on February 10, 2008.

Last week I got made an offer that I couldn’t refuse. 

Massive - the company that I’ve been working for as a contractor through the nice folks at Happener since November - offered me a full time position. I accepted, and I’m now a Senior Developer for Massive Interactive

That title sounds strange to me. Senior developer? Does that mean I’m over the hill now?
I suppose it’s somewhat similar to when I say I’m a .NET Developer, non-tech people generally go “Oh, you build websites”… not quite. (Hint: It’s a speciality in a certain set of technologies. Like saying you’re a Pediatric Nurse.)

Part of the role as a senior developer is to help provide direction to the more junior staff, so, that should be interesting to see how it works out.

Not much else has been happening - I’ve been busy with work for the most part. I’m still enjoying it, obviously.  It’s nothing like working for Telstra, which for me. is a really good thing.

What’s news with you folks?

Will’s Moving: FAQ

Posted in Work by Will on October 22, 2007.

Because people seem to be asking the same five or so questions about my new job, I thought I’d put up a FAQ.
I’m sure it won’t stop people asking anyway though :P

Who is the new job with?
It’s a contract position through an agency. Who their client is (where I’ll be working) I’m not saying yet - I’ll wait until I get to know the guys first. They’re located right in the centre of Sydney - 10 minutes from Central Station.

When do you leave / have you left Telstra yet?
My last day at Telstra is Friday the 26th of October (so, this week is my last).

When do you start at the new job?
Monday 5th November.

Are you commuting from Toronto?
Nope - I’m moving down to Sydney. A 3 hour commute *each way* really isn’t anyone’s idea of a good time.

Have you got a place in Sydney yet? / When are you moving?
Not yet. I’m staying with one of my Uncle’s first - he’s got a place about 15 minutes walk from the new job.
I’m looking for my own place at the moment, again somewhere near the centre of Sydney.

Farewell, Auf Wiedersehen, Au revoir

Posted in IT, Work by Will on September 28, 2007.

For over five years, I’ve held a bit of an open secret: I’m an alien from fluidic space.

Err, wait, let me start that again.

For over five years, I’ve been working for Telstra. I started off “on the phones”, working in a service call centre. Due to me being a smart-ass (and critical of some very inefficient systems) I was taken off the phones after about two weeks, to write some reporting tools.

From that first app in Excel 97 using VBA to generate charts, I converted to a full-time employee, and went on to bigger and better things. When I wrote that there’s a reasonably good chance of my code having touched your life in some subtle way, I wasn’t joking. The software I wrote helps people in Telstra do their jobs: Routing messages, generating reports, storing data, and keeping an eye on other applications.
I’m proud of the work I’ve done, despite it not being world changing or highly visible. Sure there’s some icky bits (VBA, Oracle, MS Access, Classic ASP), but overall I hope that it’s made people’s lives better, and/or their jobs easier, in some small way.

Today, I resigned from my position at Telstra. It’s not something I did lightly, but, after consideration I’ve decided I need to move on.

For those that are curious, I’m not going to be unemployed - Today I’ve also accepted a contract role to a digital media company in Sydney. I won’t say who, yet, until I’ve had a chance to speak with them some more, but suffice to say it looks like a great company to work for, doing interesting things and meeting interesting people.

Oh, and yes, this means that I’ll be moving from Newcastle / Toronto. I’m still at Telstra until the 26th of October and then I’ll be off to Sydney and new things.

I’d also like to throw a quick shout-out to Nick Hodge for putting in a good word for me, and listening to me rant a little about work; Jack Greenrich for plenty of coding advice and guidance; Ian Ward for getting me hired at Telstra and started down the software development path; and both Markus Hafner and Greg Dwyer of Happener Recruitment for helping me to get this new position.

Exciting times ahead, for sure…

Hello from Tech.Ed On the Gold Coast

Posted in Coding, IT, Travel, Work by Will on August 9, 2007.

The Gold Coast has put on some great weather - nice and cool at night, warm and sunny during the day.
I’ve taken a bunch of photos during Tech.Ed, I’ll upload them soon. In the mean time - Nick Hodge has heaps of photos on his photo stream.

I’ve attended a bunch of interesting sessions - but there’s a heap of information on offer, so it’s easy to overload.

Next year I think MSFT needs to organise a few more social-networking things around the events. For example, get attendees to put ‘teched07au’ tags on photos on Flickr, and blog posts, etc. Use SMS-broadcasts (possibly through twitter) to inform people of session changes and things like that (link it back to their commnet subcription).
I’ll probably think of a bunch of other small improvements as time goes on.

Overall, it’s been good fun the last few days, and I have learnt things which are relevant to my job, and which will help a little further on too.

I’ve also successfully avoided the vendors who want to steal my information so they can sell me stuff.


Updates - LOLCode.NET, Movieworld, Bye-Bye Developer Guy

_MG_6791 Nick gave his LOLCode presentation, to much incredulity by some people who attended.

Yes, LOLCode is a proper Turing complete language. And LOLCode.NET compiles into MSIL as well.

_MG_6936 Movie world was… interesting. About 3,000 people were packed into busses and trundled up to movie world for dinner and some rides.   There was the BatWing, Superman and a few others - we didn’t have access to the full park, but there was a large area open.

_MG_6823

_MG_6827

_MG_6830 

_MG_6834

_MG_6842

_MG_6856 

_MG_6875

_MG_6901

_MG_6912 

_MG_6917 

_MG_6934 

 _MG_6961 Homeward Bound

 _MG_6969

 _MG_6971

_MG_6990Frank’s “Catch Up with Frank” talk was interrupted so he could be serenaded to a version of Don McLean’s “American Pie” called “Developer Guy”.

Off to Melbourne (on Sunday)

Posted in IT, Travel, Work by Will on June 22, 2007.

I’m off to Melbourne for about 8 days, starting Sunday.

I’m going to ReMIX, catching up with work people who I havn’t met, doing a server migration… oh, and going to Paul & Chix0rs engagement party.

I’m taking the camera, and depending upon airport security, the tripod too - so I hope to take some photos whilst I’m down there.

Here’s a rough itinerary:

Sunday 24th June:
- 12:35PM: Williamtown to Melbourne, Virgin Blue Flight DJ692, Arriving 2:05pm
- Check in @ The Albany.

Monday 25th:
- 8:30 AM - 5:30 PM: ReMIX Melbourne, Day 1
- 5:30 pm - 10:00 pm WebJam & Galactic Circus festivities

Tuesday 26th:
- 8AM-5:30PM: ReMIX Melbourne, Day 2
- Dinner w/ Paul, somewhere interesting.

Wednesday 27th:
- 8AM-5PM: Work, Exhibition St.
- 5PM-7PM: Grab dinner somewhere
- 7PM-10PM: Work, Server migration & App Upgrade.

Thursday 28th:
- 8AM-5PM: Work - Exhibition St.

Friday 29th:
- 8AM-5PM: Work - Exhibition St.

Saturday 30th:
- Paul & Chickz0r’s Engagement Party

Sunday 1st July:
- 1:30pm: Melbourne to Williamtown, Qantaslink Flight QF2796, Arriving 3:55

SMS or Call me: +61 400 486 399 or 0400 486 399.

Irish Code?

Posted in Coding, Teh Funnies, Work by Will on May 16, 2007.

Q: Why did the Irishman wear two condoms?
A: To be sure, to be sure.
(Apologies to any Irish who happen to be reading this.)

I’m currently working on a project where I need to upgrade an application to support some new functionality.   This application was originally written by others,

While I was doing a review of the code, I found a segment like this (names anonymised):

        CountOfIDs = ds.Tables(“SomeTable”).Rows.Count
        Select Case CountOfIDs
            Case 0
                ‘ Do Nothing 
            Case Is >= 1
                If CountOfIDs >= 1 Then
                    ‘ Do Something
                End If
        End Select

Those IDs are slippery little things - better check twice, to be sure.
(Hint for the C#/C++/etc readers: VB doesn’t need a ‘break’ statement to exit a select/switch block)

Registered for TechEd07 On the Gold Coast

Posted in Coding, IT, Travel, Work by Will on May 13, 2007.

One big win for last week, which I havn’t mentioned was that work is picking up the tab for my TechEd 2007 ticket. (Thanks, Malcolm - even though I’m sure you don’t read my blog)

So, I’ve gone ahead and booked flights and accomodation for then.

Looks like I’m going to be busy in the next few months - Google Developer Day in Sydney on May 31st (free), ReMIX in Melbourne on June 25-26th ($140), and finally TechEd on August 7-11.

Older Entries