classpath - Bundling wsdl in jar with CXF wsdl2java -
i'm working on implementation use wsdl have gotten vendor. our project running on spring , cxf, , i'd create jar allow me access vendor's wsdl services, i'm running classpath issues.
using cxf's wsdl2java able generate code acts this:
wsdl_location = new url("file:someservice.wsdl");
the service requires wsdl in classpath, bundle in jar distributable stand-alone jar. using wsdl2java tool, able specify string in url instantiation whatever like. however, have not found combination of custom string , wsdl file location inside jar works.
the way have gotten work want put wsdl file in same folder someservice.class , use following line:
wsdl_location = trackservice.class.getresource("trackservice_v4.wsdl");
however, has downside of me having manually edit java code , compile myself. undesirable because make process part of our maven build , have wsdl2java generation , compilation automatically.
i ok wsdl being anywhere in jar, don't know pass in wsdl2java have reference file inside jar.
does have suggestions or experience doing this?
you need specify classpath wsdl location follows generate stubs uses classloader load wsdl classpath resource:
<plugin> <groupid>org.apache.cxf</groupid> <artifactid>cxf-codegen-plugin</artifactid> <version>2.4.3</version> <dependencies> <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-bindings-soap</artifactid> <version>2.4.3</version> </dependency> </dependencies> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <sourceroot>${project.build.directory}/generated-sources/cxf </sourceroot> <wsdloptions> <wsdloption> <wsdl>${basedir}/yourwsdl.wsdl</wsdl> <extraargs> <extraarg>**-wsdllocation**</extraarg> <extraarg>**classpath:yourwsdl.wsdl**</extraarg> </extraargs> </wsdloption> </wsdloptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin>
Comments
Post a Comment