Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsdlLocation generated wrong if a filename is a suffix from another #65

Open
towi opened this issue Apr 10, 2018 · 2 comments
Open

wsdlLocation generated wrong if a filename is a suffix from another #65

towi opened this issue Apr 10, 2018 · 2 comments

Comments

@towi
Copy link

towi commented Apr 10, 2018

I think here is an error in the logic to find out the relative path for the wsdlLocation to generate:

private String getRelativePath( File f )
{
    if ( wsdlFiles != null )
    {
        for ( String s : wsdlFiles )
        {
            String path = f.getPath().replace( File.separatorChar, '/' );
            if ( path.endsWith( s ) && path.length() != s.length() )
            {
                return s;
            }
        }
    }

My config is roughly like this:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.5</version>
    <executions>
      <execution>
        <goals>
          <goal>wsimport</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <target>2.1</target>
      <sourceDestDir>${project.build.directory}/generated-sources/jaxws-maven-plugin</sourceDestDir>
      <wsdlDirectory>${project.build.directory}/jaxwsinput</wsdlDirectory>
      <wsdlFiles>
        <wsdlFile>GreatStuff.wsdl</wsdlFile>
        <wsdlFile>EvenMoreGreatStuff.wsdl</wsdlFile>
      </wsdlFiles>
      <wsdlLocation>/*</wsdlLocation>
...

The wsdlLocation for EvenMoreGreatStuff.wsdl becomes /GreatStuff.wsdl because "GreatStuff" is a suffix of "EvenMoreGreatStuff":

@WebServiceClient(name = "EvenMoreGreatStuffService", 
    targetNamespace = "http://j2ee.netbeans.org/wsdl/EvenMoreGreatStuff", 
    wsdlLocation = "/GreatStuff.wsdl")
public class EvenMoreGreatStuffService
    extends Service

If the order of the <wsdlFile> entries is swapped, all is fine. The loop for ( String s : wsdlFiles ) then finds the correct file first.

@towi
Copy link
Author

towi commented Apr 10, 2018

I added a unittest that currently fails:

@Test
public void testRelativePathSufixesIssue65() {
    // arrange
    final WsImportMojo instance = new WsImportMojoMock();
    instance.wsdlFiles = new ArrayList<String>();
    instance.wsdlFiles.add("GreatStuff.wsdl");
    instance.wsdlFiles.add("EvenMoreGreatStuff.wsdl");
    // act
    final String result = instance.getRelativePath(new File("EvenMoreGreatStuff.wsdl"));
    // assert
    Assert.assertEquals(result, "EvenMoreGreatStuff.wsdl");
}

WsImportMojoTest.java.txt

@fguillod
Copy link

I confirm this issue, I encountered the same problem with version jaxws-maven-plugin 2.6. My two wsdl names are Services.wsdl and CallbackServices.wsdl, and the wsdlLocation="" is only generated correctly if CallbackServices.wsdl is listed first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants