0

When we generate a stub using WSDL that will have this line below in class.

@WebServiceClient(name = "testService", targetNamespace = "http://test.soap.coh.mycompany.com/", wsdlLocation = "file:/C:/Users/sam/Documents/NetBeansProjects/test/trunk/test-service-co/target/wsdl/co/test/wsdl/testService.wsdl")
This is good when you are deploying the ear in local means same place where you have the source code.
But when we try to develop this ear pacakge created from my desktop in dev server its is giving exception, as the path is not avilabel.

Now my question id how to generate the stub where we do not have the above mentioned issue. Please note we are using maven to generate the stubs.

2 Answers2

0

Generate stubs dynamically at deploy time

  • Do not include stub implementation classes in your generic build
  • Make sure Webservice is up and running for respective environment
  • At deploy time, execute a script that will generate stubs based off WSDL that is published for respective environment
Gladwin Burboz
  • 3,519
  • 16
  • 15
0

If you are using CXF/Jaxws you can do it like this

<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.basedir}/src/main/resources/wsdl/FooService.wsdl</wsdl>
            <wsdlLocation>classpath:wsdl/FooService.wsdl</wsdlLocation>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Instead of classpath location you can also give just FooService.wsdl

Reference: How to avoid the need to specify the WSDL location in a CXF or JAX-WS generated webservice client?

If you are using jaxws-maven-plugin to configure, then I belive above options can be configured for JAXWS WsImport compiler from Maven2 in it's jaxws:wsimport configuration section. I have not tried this myself though.

Community
  • 1
  • 1
Gladwin Burboz
  • 3,519
  • 16
  • 15