Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

wsdl - Maven: extract files from jar

I'm developing a client application of a WebService and I have the corresponding WSDL file inside a jar.

I'm using ant to generate the java code from the wsdl with the following build.xml:

<project name="wsimport" default="wsimport" basedir=".">
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" />

  <target name="wsimport">
     <echo message="Starting wsimport"/>
     <mkdir dir="target/generated-sources/jaxws-wsimport"/>
     <wsimport
        wsdl="???"
        sourcedestdir="target/generated-sources/jaxws-wsimport"
        extension="true"
        verbose="true"
        target="2.0"
        xnocompile="true"
        catalog="src/jax-ws-catalog.xml"
        wsdlLocation="/MyWebService/MyWebServiceV1_0?wsdl">
        <binding dir="src/main/resources/bindings/v1_0" includes="*.xml"/>
        <xjcarg value="-XhashCode"/>
        <xjcarg value="-Xequals"/>
        <xjcarg value="-XtoString"/>
     </wsimport>

   </target>
</project>

How do I load the WSDL file from a jar? The WSDL references an XSD which is also in the same jar.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Answering to my own question, the approach I used was to extract the files from the jar.

Actually I use maven to build the project and the antrun plugin to generate the sources from the wsdl, so I used the maven-dependency-plugin to unpack the files from the jar:

            <!-- extract WSDL and XSD from dependency jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>my.company</groupId>
                                    <artifactId>my.artifact</artifactId>
                                    <version>1.0</version>
                                    <outputDirectory>${project.build.directory}/wsdl</outputDirectory>
                                    <includes>**/*.xsd, **/*.wsdl</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...