Tuesday, September 30, 2008

WSDL in ActionScript

One of the advertised features of Adobe's Flex Builder is that it works with web services. Indeed, in any project you can import a WSDL and Flex Builder will generate lots of code for you. The resulting generated code states that the code generator is based on Apache Axis2, and it looks like it. This is mostly a good thing.

This is ok for a single developer or even a small team. Once you get to larger scale development, you usually want to keep code generated artifacts separate for the source code that generated them. Often you never want to check-in generated code. Why? Because then you have two sources of truth: the artifact (WSDL in this case) and the generated code. You don't want to have to keep these things in sync manually, you want your build process to do it. So you don't check in the generated code, and your build system generates it instead.

So ideally the code generation in Flex Builder could be invoked outside of Flex Builder. This may be the case, but so far I have no luck in this. It is certainly not a documented part of the SDK.

I looked for an alternative and found wsdl2as. This looked promising, but did not work out. First, it expects you to send in XML literals when sending SOAP messages. Sure it generates the boilerplate around the core message, but if I wanted to work directly in XML, I would not have bothered with a code generator. It has an option that seems designed to deal with this, but did not. Even worse, it does not handle anything except the simplest WSDLs. The first WSDL I tried with it defined complex types for the input parameter and return type of the web service. This caused wsdl2as to choke, as it expected any type information to be inlined. Sigh.

4 comments:

Josh McDonald said...

I've found that in practice your best option with Flex is using good support libraries to automate as much of the VO -> request -> server -> response -> VO path. Utils to map VOs to/from Flex's inbuilt ObjectProxy <-> WebService translation seems to be the sweet-spot for me.

There are unfortunately some bugs in the decoding code, but I only know of one that I'm yet to fix, and I should get to that soon ;-)

As woeful as the WSDL -> Code utility in builder is, often I find when things go wrong it's because Flex is doing the right thing and Oracle / soapUI / The SOA toolkit we use is the actual problem. And don't get me started on XFire!

Anonymous said...

Im Bruce Young. Cool ideas to run a programmen blog. Its very use fulr to people.

Thanks


Bruce Young
__________________________

Bruce Young, Napa, California 94558 - SSN, Credit Records, Arrest Records, Court Records, Criminal Records ..

nha said...

I have to agree with this assessment. Open sourcing the wsdl generator in flex builder would be my favorite solution to this problem.

Mary Petter said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog.
Really very informative post you shared here. Kindly keep blogging.
If anyone wants to become a Front end developer learn from Javascript Online Training from India .
or learn thru JavaScript Online Training from India.
Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Training in Chennai