Geertjan's Blog

  • August 30, 2005

Exposing Generated Web Service Client Files in the NetBeans Projects Window

Geertjan Wielenga
Product Manager
In Eating Web Services in NetBeans IDE 4.1, I complained about the fact that the client files generated by the NetBeans Web Service Client wizard end up stuck away deep in the Files window:

Of course, the extent to which the generated client files are hidden depends on the number of subpackages that you define for them. However, nonetheless, your generated client files are stuck far away from where you would want them -- the Projects window, where you work with the JSP, servlet, or other Java class that uses these client files to interact with the web service. If, for example, there's a getQuote method made available by the web service, you can see that very easily by looking in the Web Service References node in the Projects window. However, what if the web service includes complex types, which the IDE converts to Java POJOs? You need to do a lot of digging to work out (a) what the Java POJOs are and (b) what methods they make available.

Today I was told by Milan Kuchtiak about a very cool workaround (which has one very fatal flaw), specifically for the situation described above. Right-click the project node and then, in the Project Properties dialog box, add the top-level package in which the generated client files are found as a source root in the Sources panel (click to enlarge):

The benefits of doing this are as follows:

  • The folder that you specified immediately appears in the Projects window:

  • Code completion is available in the Source Editor for the generated client files:

  • When you press Alt-Shift-O (Go To Class), the classes are found (although, why they're found twice is a bit of a mystery to me):

However, one big disadvantage is that you shouldn't assume that you can now add Java classes to that new folder in your Projects window! As soon as you run the Clean Project command, they'll be gone. (On top of that, of course, you shouldn't ever want to add files to that package anyway -- it's only there for your generated client files.) And that's probably why the generated client files aren't displayed in your Projects window by default -- files that are deleted during a Clean Project command are never exposed in the Projects window by default. However, if -- as in this scenario -- you need them to be there, you can take the steps to put them there manually, by yourself, and not blame anyone other than yourself when you accidently forget that the folder is going to be deleted the very next time you choose Clean Project...

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.