0

I am trying to use resource filtering to generate the SOAP addresses for WSDLs. But somehow it is not working. I have written the plugin and resource element as:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <inherited>false</inherited>
    <executions>
        <execution>
            <id>process-urls</id>
            <phase>clean</phase>
            <goals>
                <goal>resources</goal>
            </goals>
            <inherited>false</inherited>
            <configuration>
                <delimiters>
                    <delimiter>${*}</delimiter>
                </delimiters>
                <filters>
                    <filter>src/main/resources/PO/WSDLFiles/ProcessOrder.wsdl</filter>
                    <filter>src/main/resources/DAC/WSDLFiles/InternalRequest.wsdl</filter>
                </filters>
                <overwrite>true</overwrite>
            </configuration>
        </execution>
    </executions>
</plugin>

<resources>
    <resource>
        <directory>src/main/resources/</directory>
        <includes>
            <include>**/*</include>
        </includes>
        <filtering>true</filtering>
    </resource>
</resources>

I have some profile values defined under, ${protocol}, ${fullhostname} and ${port}

The WSDL tag, that I want to get modified is like:

<service name="ProcessOrderService">
    <port name="ProcessOrderSoapHttpPort" binding="tns:ProcessOrderSoapHttpBinding">
        <soap:address location="${protocol}://${fullhostname}:${port}/PO/services/ProcessOrderSoapHttpPort"/>
    </port>
</service>

When I run my pom file which also has a CXF plugin to generate classes I see that the URL in the JAVA objects get generated with:

${protocol}://${fullhostname}:${port}/PO/services/ProcessOrderSoapHttpPort

It just picks up the string as-is, with no values applied. Can you please tell me what I am doing wrong? I am guessing the "" in the WSDL attribute is causing the problem but I might be wrong.

hell_storm2004
  • 1,401
  • 2
  • 33
  • 66

1 Answers1

0

I assume Maven Resources Plugin works as intended. If you use debug mode mvn clean install -X you will find some additional info like:

[DEBUG] file ProcessOrder.wsdl has a filtered file extension
[DEBUG] filtering /work/source/stackoverflow/wsdl-filtering/src/main/resources/PO/WSDLFiles/ProcessOrder.wsdl to /work/source/stackoverflow/wsdl-filtering/target/classes/PO/WSDLFiles/ProcessOrder.wsdl
[DEBUG] no use filter components

If no <outputDirectory> was specified the default output folder will be ${project.build.outputDirectory} (target/classes).

In this case just specify wsdl file locations in CXF plugin:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${project.build.outputDirectory}/PO/WSDLFiles/ProcessOrder.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Do not use the same directory because you will lost the content of original file. The result will an empty wsdl file.

Additionally I recommend to fix Resources Plugin Configuration. You use <filters> which is for defining properties file which contains key-value pairs. Use <resources> and <include> instead as you did in the build section.

zforgo
  • 2,508
  • 2
  • 14
  • 22
  • So you are suggesting drop the resource plugin altogether? And just rely on resources/filter tags under the build section.... am I right? – hell_storm2004 Jan 03 '20 at 08:04