2016-05-16 6 views
0

Ich habe ein EJB-Projekt (in Websphere ausführen), die auch ein WebService-Client ist. Zuvor haben wir die Clientklassen manuell mit dem Befehl wsimport erstellt. Jetzt wollen wir den Prozess mit dem , Ziel jaxws:wsimport automatisieren.Wie @Stateless mit wsimport generieren

Die Generation ist fast perfekt, abgesehen von einer Tatsache: die Webservice-Klassen (mit der Anmerkung @WebService) sollten auch die @Stateless Annotation haben. Ohne dies beschwert sich Eclipse, dass die Annotation @WebService in EJB-Modulen nur für Stateless-Session-Beans verwendet werden kann. Tatsächlich hatten die früheren Versionen dieser Klassen (die vermutlich mit manuell wsimport erstellt wurden) die Annotation @Stateless.

Ich nehme an, dass es einige Konfiguration wsimport zu sagen haben sollte die Klassen als Stateless zu erzeugen. Allerdings habe ich es weder in der wsimport Dokumentation noch im Maven Plugin gefunden.

Im Folgenden werde ich meine POM Konfiguration zeigen:

<properties> 
    <wsdl.dirs>${basedir}/src/main/resources/META-INF</wsdl.dirs> 
    <wsdl.package.basic>com.porto.sinistro.orcamentomultiempresa</wsdl.package.basic> 
</properties> 

<plugin> 
    <groupId>org.jvnet.jax-ws-commons</groupId> 
    <artifactId>jaxws-maven-plugin</artifactId> 
    <version>2.3</version> 
    <executions> 

     <!-- 
     Other executions, using other WSDL files. 
     --> 

     <execution> 
      <id>wsdl-cartaAutorizacao-exec</id> 
      <goals> 
       <goal>wsimport</goal> 
      </goals> 
      <configuration> 
       <packageName>${wsdl.package.basic}.upload.cartaAutorizacao.client</packageName> 
       <wsdlFiles> 
        <wsdlFile>${wsdl.dirs}/CartaAutorizacaoWSService.wsdl</wsdlFile> 
       </wsdlFiles> 
       <wsdlLocation>META-INF/CartaAutorizacaoWSService.wsdl</wsdlLocation> 
      </configuration> 
     </execution> 

    </executions> 

    <configuration> 
     <bindingDirectory>${basedir}/src/main/java</bindingDirectory> 
     <sourceDestDir>${basedir}/src/main/java</sourceDestDir> 
     <verbose>true</verbose> 
     <target>2.0</target> 
     <xnocompile>true</xnocompile> 
    </configuration> 

    </plugin> 
</plugins> 

Für die WSDL oben erwähnt, hat die WebService-Klasse dieses Formular:

@WebService(name = "CartaAutorizacaoWS", targetNamespace = "http://client.ws.soma.upload.sinistro.porto.com/cartaautorizacao") 
// Where is the @Stateless? 
public interface CartaAutorizacaoWS { 
    // ... 
} 

Welche Konfiguration sollte ich @Stateless WebServices zu generieren tun?

Danke,

Rafael Afonso

Antwort

0

fand ich meine Lösung ANT verwenden.

Meine POM-Datei wurde geändert:

<plugin> 
    <groupId>org.jvnet.jax-ws-commons</groupId> 
    <artifactId>jaxws-maven-plugin</artifactId> 
    <version>2.3</version> 
    <executions> 

     <!-- 
     Other executions, using other WSDL files. 
     --> 

     <execution> 
      <id>wsdl-cartaAutorizacao-exec</id> 
      <goals> 
       <goal>wsimport</goal> 
      </goals> 
      <configuration> 
       <packageName>${wsdl.package.basic}.upload.cartaAutorizacao.client</packageName> 
       <wsdlFiles> 
        <wsdlFile>${wsdl.dirs}/CartaAutorizacaoWSService.wsdl</wsdlFile> 
       </wsdlFiles> 
       <wsdlLocation>META-INF/CartaAutorizacaoWSService.wsdl</wsdlLocation> 
      </configuration> 
     </execution> 

    </executions> 

    <configuration> 
     <bindingDirectory>${basedir}/src/main/java</bindingDirectory> 
     <sourceDestDir>${basedir}/src/main/java</sourceDestDir> 
     <verbose>true</verbose> 
     <target>2.0</target> 
     <xnocompile>true</xnocompile> 
    </configuration> 

    </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.8</version> 
      <executions> 
       <execution> <!-- Eclipse error message. See below. --> 
        <id>inject-stateless</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <tasks> 
          <ant antfile="${basedir}/inject-stateless.xml" target="main" /> 
         </tasks> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

</plugins> 

Mein ANT Script:

<?xml version="1.0"?> 
<project default="main" basedir="."> 
    <property name="base.source.dir" value="./src/main/java/com/porto/sinistro/orcamentomultiempresa"/> 

    <target name="main" > 
     <antcall target="replace"> 
      <param name="file.path" value="client/controlevagas/ControleVagasWeb.java"/> 
     </antcall> 
     <antcall target="replace"> 
      <param name="file.path" value="client/somavistoriaweb/VistoriaWeb.java"/> 
     </antcall> 
     <!-- Other java files ... --> 
    </target> 

    <target name="replace"> 
     <property name="java.file" location="${base.source.dir}/${file.path}"/> 
     <echo message="Ajustando classe ${java.file}"/> 
     <replace file="${java.file}"> 
      <replacetoken><![CDATA[import javax.jws.WebMethod;]]></replacetoken> 
      <replacevalue><![CDATA[import javax.ejb.Stateless; 
import javax.jws.WebMethod;]]></replacevalue> 
     </replace> 
     <replace file="${java.file}"> 
      <replacetoken><![CDATA[public interface]]></replacetoken> 
      <replacevalue><![CDATA[@Stateless 
public interface]]></replacevalue> 
     </replace> 
    </target> 

</project> 

Obwohl meine Eclipse-Nachricht Fehler zeigt Plugin Ausführung nicht durch Lifecycle-Konfiguration abgedeckt: org.apache.maven .plugins: Maven-antrun-Plugin: 1,8: run (Ausführung: injizieren-staatenlos, Phase: generieren-Quellen), entdeckte ich, dass es keine Auswirkungen auf die Maven Ausführung hatte. Siehe meinen Beitrag Maven (m2e) is not executing ant task.

Verwandte Themen