开发者

In Netbeans+Ant, how do I avoid wsimport rebuilding web service clients every build?

I'm on a project where we use NetBeans (6.8). We use several different web services, which we have added as web service references, and Netbeans auto-generates the Ant wsimport scripts for us. Very handy, with one drawback: The web service clients are recompiled every time ant is invoked. This slows down the build process considerably 开发者_如何学Pythonand has caused the number of sword-related injuries, maimings and deaths to skyrocket.

Normally, I'd fix this by changing the wsimport element from

<wsimport 
    sourcedestdir="${build.generated.dir}/jax-wsCache/PonyService"
    destdir="${build.generated.dir}/jax-wsCache/PonyService"
    wsdl="${wsdl-PonyService}" 
    catalog="catalog.xml" 
    verbose="true"/>

to

<wsimport 
    sourcedestdir="${build.generated.dir}/jax-wsCache/PonyService"
    destdir="${build.generated.dir}/jax-wsCache/PonyService"
    wsdl="${wsdl-PonyService}" 
    catalog="catalog.xml" 
    verbose="true">
    <produces dir="${build.generated.dir}/jax-wsCache/PonyService" />
</wsimport>

But I can't, 'cause this part of the Ant script is auto-generated. If I right-click the PonyService web service reference and select Edit Web Service Attributeswsimport options, I can add attributes to the wsimport element, but not child elements.

So: How do I add the produces child element to wsimport other than hacking the auto-generated Ant script?

Or more generally: How do I make the NetBeans-generated wsimport not recompile the web service clients every time I build?

(Also featured on the NetBeans EE forum.)


I may have an answer to this moldy question. The auto-code generation is intended to provide the Project with a web service client. The code is generated under a separate Web Service package folder, and the generated package is under that. Once that code has been generated, auto-generation is no longer required. The code is there to be used.

BACKUP EVERYTHING BEFORE DOING ANYTHING!

Drag/drop the generated code package from that folder to your primary source folder. The Web Service package folder disappears of course because nothing is in there. The Web Service client definition remains - this is where we'd typically refresh the definition. Delete that. It's no longer needed. Now do a Clean Rebuild. The result is a package of code within your project that looks just like everything else you've written - and the remote web service is not queried on every build.

Yes, you've lost the ability to dynamically regenerate the code from the WSDL, but if you really need to do that, just rename the current package, then regenerate new code and repeat as above and delete the redundant code when you're comfortable. You can also delete the META-INF nodes from the source tree. I found it took a couple delete operations to do this. After deleting everything except the .java code modules and doing a rebuild. My code did the remote connection without a problem.

I did as above when I realized that the generated code was being ignored by Subversion. The generated folders didn't contain a .svn file, so I couldn't commit that code into my repository. The only way to integrate the code into the project was to physically copy it in - and then I realized that this other problem was also solved.

It took 2 years to get a solution but I hope this helps someone...


Have you tried NetBeans 6.9? I only ask because my jaxws-build.xml looks different to yours (all auto-NetBeans-generated).

<wsimport 
    sourcedestdir="${build.generated.dir}/jax-wsCache/ListProductsService" 
    destdir="${build.generated.dir}/jax-wsCache/ListProductsService"
    wsdl="${wsdl-ListProductsService}"
    catalog="catalog.xml"
    extension="true"
    verbose="true" 
    wsdlLocation="file:/C:/NetBeansProjects/wsclient/ListProductsService.wsdl" 
    xendorsed="true">
    <depends file="${wsdl-ListProductsService}"/>
    <produces dir="${build.generated.dir}/jax-wsCache/ListProductsService"/>
</wsimport>

The above wsclient project is able to be cleaned and built without the web service reference being online.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜