如何从依赖项jar中引用wsdl文件?

时间:2020-11-04 18:56:53

标签: java maven weblogic java-ee-7

我有3个模块:

api模块包含xsd + wsdl文件,并在编译期间使用来自Apache的cxf-codegen-plugin生成Java对象。

service模块实现了api生成的接口,该接口作为依赖项导入。

然后ear模块从service构建耳包。

这是服务定义的方式:

@Stateless
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
@WebService(portName = "blabla",
        serviceName = "blabla",
        targetNamespace = "http://blabla",
        wsdlLocation = "META-INF/wsdl/mywebservice.wsdl", // this should be relative to the api jar
        endpointInterface = "blabla")
@SchemaValidation
public class MyWebServiceImpl implements MyWebService {}

问题是,我们注意到,如果不指定wsdlLocation,则模式验证将不起作用,因此需要添加它。但是我们不知道如何引用它,而无需将wsdl文件直接添加到service jar的根目录中。我们进行以下组装(位于服务模块中):

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>resources</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <includes>
                <include>service-artifact</include>
            </includes>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <scope>runtime</scope>
            <unpack>true</unpack>
        </dependencySet>
        <dependencySet>
            <includes>
                <include>api-artifact</include>
            </includes>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <scope>runtime</scope>
            <unpack>true</unpack>
            <unpackOptions>
                <includes>
                    <include>META-INF/wsdl/**</include>
                </includes>
            </unpackOptions>
        </dependencySet>
    </dependencySets>
</assembly>

我想摆脱这一点,因为我认为没有必要这样做,因为依赖性已经存在。

0 个答案:

没有答案
相关问题