JAX-WS Loading WSDL from jar

前端 未结 13 937
予麋鹿
予麋鹿 2020-11-28 04:40

I\'m writing a fat client that makes use of a SOAP service for some features (bug reporting etc.)

I\'ve got JAX-WS working fine, but by default (in netbeans at least

13条回答
  •  离开以前
    2020-11-28 05:29

    Atleast for the recent JAX-WS you don't need to do any schema catalogs or programmatic wsdl location setting IF you put the WSDL in the JAR and then set wsimport wsdlLocation to the relative resource path of the WSDL in the JAR. That is JAX-WS uses Java's builtin Class.getResource to load the WSDL.

    If your using Maven its something like:

      
        org.jvnet.jax-ws-commons
        jaxws-maven-plugin
        2.3
        
          
            
              wsimport
            
            
            
                
        /com/adamgent/ws/blah.wsdl
        ${basedir}/src/main/resources/com/adamgent/ws
        blah.wsdl
           
          
        
      
    

    For the example above you would thus put the WSDL using Maven project layout here src/main/resources/com/adamgent/ws.

    Make sure the WSDL gets in the JAR for Maven like:

    
          
            
              src/main/resources
            
           ....
    

    Now your wsimport generated code and WSDL are in a self contained JAR. To use the service you do not have to set the WSDL location and is as easy as:

    BlahService myService = new BlayService_Service().getBlahServicePort();
    

    It should be trivial to map this over to ANT's wsimport.

提交回复
热议问题