Monday, September 24, 2007

One of the very difficult to solve problems in .NET client & web service solutions is sharing custom objects between the web service and the client.

Here's the scenario.

You have a business layer with some serializable objects. Let's say the namespace is "MyLovelyBAL" and the object is "MyLovelyObject".

You have an operation in your web service that returns one of those objects.

Now you build a client, say a Windows Forms app ("MyWinApp") that will call into that Web Service, and you are not savvy enough to use a tool like thinktecture's WSCF. :-) Therefore you "Add Web Reference" and point to the web service you built. In doing so, you are asked to give a name to the proxy. Let's call that "MyWSProxy".

In your WIndows Forms app, you also have a reference to the assembly that contains MyLovelyBAL.MyLovelyObject.

Now it's time to write some code.

You instantiate the proxy and request a lovelyobject.

Dim myproxy = New MyWSProxy.Service
Dim MyLovelyBAL.MyLovelyObject=myproxy.GetMyLovelyOBject

But it fails telling you that you can't cast a MyWinApp.MyWSProxy.MyLovelyObject to a MyLovelyBAL.MyLovelyObject.

And then you will begin on a journey to hell, which might include reading this article on Schema Providers which is not for the feint of heart.

So just forget it. It's 2007! We have WCF.

You can go into your project where you define the MyLovelyObject class and give it a DataContract attribute and give it's properties (that you want to expose) DataMember attributes. Your interface operation (and any operations that implement it) will return a MyLovelyBAL.MyLovelyObject object.

And when you Add Service Reference to your windows forms app, there is no namespace replacement. A "MyLovelyObject" is always coming from MyLovelyBAL and this is oh, so lovely. The way it oughtta be!

You know I learned this the hard way. And I will be seeing Michele Leroux Bustamante tomorrow who will first bop me on the head for waiting so long to use WCF and the sit me down and have me read her fabulous book Learning WCF, (which I had in my hands long enough to raffle off at VTdotNET last week BOO HOO) cover to cover. It's about time!

Monday, September 24, 2007 2:23:08 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, July 01, 2007
Sunday, July 01, 2007 11:53:58 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
 Monday, May 08, 2006

WCF is so hip, even water is getting in on the act!

(sorry, just couldn't resist :-) )



Posted from BLInk!
Monday, May 08, 2006 9:43:41 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Thursday, April 06, 2006

Ahh, I'm a day late and a dollar short. Yesterday the PAG Team announced Service BAT - Service Baseline Architecture Toolkit - that will guide and help you implement WCF and ASMX services. They have had a bunch of plumbers helping them out including Christian Weyer and Pablo Cibraro. I can't wait to get my hands on it. This type of tooling will help take another layer of fear (and unintentional bad design) allowing WCF to be accessible to a lot more people.

Here's Jason Blogg's announcement.

Edward Bakker has some good details.



Don't Forget: www.acehaid.org
Thursday, April 06, 2006 7:49:25 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, March 31, 2006

Everything I thought I knew about how to interop messages between WCF and WSE3.0 went down the toilet with the newest bits of WCF.

Thanks to some serious counseling from William Tay this morning (who has been diving deep with WCF for a long time and has also kept up with the changes that affect all forms of interop, even WSE3.0) and then lots of hours of just trying, failing, thinking, adjusting (rinse and repeat) I finally got a WCF client app to talk to a WSE3.0 secured web service using a UsernameforCertificate binding/policy.

And yes, it's all secured on the wire. I had every problem. Wrong X509 certificates installed, wrong encryption algorithms, hitting a few WCF bugs and more. Luckily, all of the work I have done with WSE3.0 has helped me prepare for troubleshooting this stuff. To me, that is one of the most important lessons!

Here are a few of the things I can share.

I was doing what Willie tells me is the hardest thing with interop - UsernameOverCertificate. But being bullheaded I had to go forward with it.

I tried writing my own, but didn't understand well enough (though now I think I could tackle that) and instead used WSEHttpBinding that is a custom binding in one of the WCF samples.

That binding uses the Aes128 algorithm for it's default security binding and secure conversation. I kept getting a message that the algorithm was insufficient to encrypt and key wrap. Changing them both to Aes256 fixed that. It took me a while to realize there were two spots to change, but I had the right idea! Uggh.

At one point, I was still getting an error, but looking at the web service's trace, I could see that everything on that end had finally happened correctly. Therefore the problem was on the client side. Google gave me ONE response, and naturally it was from a blog post of Willie's! He had seen a similar problem in the Sept. CTP, but it was enough to fix my problem (Feb CTP).

Since this stuff is still in flux, I think I will wait for WCF beta2 to be released before I attempt to update my article on preparing WSE3 web services for WCF. Truly the hard part (until the new bits are all sorted out) is writing the WCF client. I didn't have to do anything to my web service to get this to work.

Willie's got a pair of great articles on WCF on The Server Side (first, second) and I hear there's a WSE3/WCF interop article coming soon from him as well. Lucky or the rest of us!

I will never have the deep knowledge of this stuff hat Willie and his compadres (Michele Butamante, Christian Weyer, Juval Lowy, etc.) have, but as long as I am willing to battle this stuff out so that I can share it with other programmers who are floating on the surface, I'll keep at it.

I'll be looking at more of this stuff in my WSE3 for WCF session at DevConnections next week. My focus is on making sure the WSE3 services are written correctly so that you can talk to them in the future from WCF. I won't be teaching WCF. You can go across the hall to see Michele for that.



Don't Forget: www.acehaid.org
Friday, March 31, 2006 3:28:01 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, March 27, 2006

Not only can you write web services today that can be consumed by WCF (Indigo) apps in the future, but working with WSE 3.0 today to secure your web services will also help you get a handle on many of the concepts of WCF. I have written an article for DevSource called "Using WSE 3.0 Today to Secure Web Services Tomorrow" based on current guidance (based on WSE 3.0 and WCF Beta 1) on just such a topic.

I will also be doing a talk on this topic next week at DevConnections.

Thanks to Mark Fussell for his insights on this topic.



Don't Forget: www.acehaid.org
Indigo | WSE
Monday, March 27, 2006 1:43:04 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, March 22, 2006

The January CTP install notes recommend installing the WinFX components before VS2005, but according to Michele Leroux Bustamante, who has done a LOT of work with WCF, if you are working with the newer (non go-live) February CTP  release, it's okay to install all of theWinFX ontop of VS2005. This is great to know because I can store a copy of a VPC with WinXp and VS2005 already installed, then use it when testing new WinFX bits as they are released.

See Michele's blog post for links and installation order.



Don't Forget: www.acehaid.org
Wednesday, March 22, 2006 12:22:50 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Tuesday, March 21, 2006

It seems like just yesterday that I was asking around about how Atlas interacts with WS-Security and other WS* compliant web services created using tools like WSE or WCF. And woudntchaknowit! The Atlas version that was released just yesterday has WCF extensions built right in for seamless communication with WCF.

Oddly, I came across the link on the Atlas site today not knowing that it wasa brand spanking new page, and therefore was feeling  a bit embarrassed that I had completely missed this before! :-)

It wasn' until I saw Steve Maine's post that I realized it hadn't been up there for long!



Don't Forget: www.acehaid.org
Tuesday, March 21, 2006 10:13:38 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, February 25, 2006

William Tay (aka Softwaremaker), a WCF wizard, has an article on TheServerSide.Net which is a great intro to programming with WCF.



Don't Forget: www.acehaid.org
Saturday, February 25, 2006 5:30:09 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, February 20, 2006
I'm looking at Rod Paddock's editorial in the current CoDe Mag issue. This is the future tehcnologies issue wiht articles on WPF, LinQ and Ajax. In the editorial he says that there is going to be a 6 article series on WCF starting with the next issue. I'm really looking forward to this. Especially considering who is going to be writing some of these: Michele Leroux Bustamante, Juval Lowy, Christian Weyer.

Don't Forget: www.acehaid.org
Monday, February 20, 2006 9:37:21 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Thursday, January 19, 2006

The January CTP of WinFX (which includes WCF) is available on MSDN online. Note some good advice on installation from Charles Petzold.

WCF and it's pal Windows Workflow Foundation were anointed with GoLive licenses. The runtimes associated with these can be downloaded here.

WCF gets a home on the web at www.windowscommunication.net.



Don't Forget: www.acehaid.org
Thursday, January 19, 2006 5:33:46 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Thursday, October 20, 2005

Tim Ewald's recent talk at Vermont.NET got me fired up about contract first again. Read more here...

[A DevLife post]



Don't Forget: www.acehaid.org
Thursday, October 20, 2005 9:31:52 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, October 15, 2005

I have a self-hosted service which I am calling through it's proxy in a client app.

When the service has multiple endpoints, svcutil adds "ConfigurationName" properties to the endpoints in the config file. With a single endpoint, that parameter is not necessary.

When instantiating the service via the proxy, I was following a single endpoint example and forgot to indicate *which* endpoint or configuration I wanted. Thus my code:

ServiceProxy myproxy=new ServiceProxy();

gave me an error when it hit the proxy's constructor and I was given the following exception:

could not find endpoint element that references contractType [whatever my contract name is]

Oddly, if I found that if I removed ConfigurationNames from the config, the app will actually run and somehow randomly selected from the multiple endpoints.

The exception message led me on a very wild goosechase. But luckily, Softwaremaker, who is quite the Indigo guru already, asked me a key question: "how are you instatiating the proxy?"

Since all of this stuff is so new, I am placing this mistake out on Google for the next person who makes this mistake.


Don't Forget: www.acehaid.org

Saturday, October 15, 2005 3:09:41 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, October 10, 2005

I'm not kidding.

By changing a WCF binding from basicHttpBinding to wsHttpBinding, bingo bammo magic right before my very eyes! My messages were encrypted. I did nothing else.

Here's where I got my inspiration...thanks Ami.



Don't Forget: www.acehaid.org
Monday, October 10, 2005 5:09:24 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

As I am tightening up my Indigo demos for TechEd South Africa, I am going over a bunch of posts by Michele Leroux Bustamante which is helping me sort out "just getting it to run" vs. "writing services properly". [read more ...]

[A DevLife post]



Don't Forget: www.acehaid.org
Monday, October 10, 2005 10:57:07 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, October 09, 2005

I need to stamp this onto my brain so that it flows from my tongue as readily and thoughtlessly* as the word "Indigo":

"Secure, Reliable, Transacted Web Services"

*thoughtlessly as in: I don't have to stop and think "what is that phrase again?", it's just there...



Don't Forget: www.acehaid.org
Sunday, October 09, 2005 2:08:15 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, October 02, 2005

My key take-aways from Clemens Vasters' introduction to Indigo article [read more...]

[A DevLife post]



Don't Forget: www.acehaid.org
Sunday, October 02, 2005 4:57:26 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
Michele Leroux Bustamante is posting a lot of useful how-tos on Indigo Check out www.dasblonde.net.

Don't Forget: www.acehaid.org
Sunday, October 02, 2005 9:49:18 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, September 30, 2005

... One great resource is Omri Gazitt's weblog post Porting from Beta1 to Beta2. This helped me resolve most of the problems that I was having with changed attribute names. Omri is on the Indigo team at Microsoft and I will be taking a look at his presentation decks from PDC this weekend.

There was one holdover that was still lingering in my config file though, the securityMode attribute in the [read more...]

[A DevLife post]



Don't Forget: www.acehaid.org
Friday, September 30, 2005 9:45:56 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  |