汪菘
2 years ago
10 changed files with 135 additions and 4 deletions
Binary file not shown.
@ -0,0 +1,23 @@ |
|||||
|
package org.nl.acs.ext.wms.service.wsdl; |
||||
|
|
||||
|
import java.lang.annotation.ElementType; |
||||
|
import java.lang.annotation.Retention; |
||||
|
import java.lang.annotation.RetentionPolicy; |
||||
|
import java.lang.annotation.Target; |
||||
|
|
||||
|
/** |
||||
|
* <p>description:自动发布接口地址注解</p> |
||||
|
* |
||||
|
* @author newzhong |
||||
|
* @version 1.0 |
||||
|
*/ |
||||
|
@Target({ElementType.TYPE}) |
||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||
|
public @interface AutoPublish { |
||||
|
/** |
||||
|
*<p>description:发布地址</p> |
||||
|
* @return String |
||||
|
* @author newzhong |
||||
|
*/ |
||||
|
String publishAddress(); |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.nl.acs.ext.wms.service.wsdl; |
||||
|
|
||||
|
import org.apache.cxf.Bus; |
||||
|
import org.apache.cxf.bus.spring.SpringBus; |
||||
|
import org.apache.cxf.feature.LoggingFeature; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
|
||||
|
public class CxfConfig { |
||||
|
@Bean(name = Bus.DEFAULT_BUS_ID) |
||||
|
public SpringBus springBus() { |
||||
|
SpringBus bus = new SpringBus(); |
||||
|
bus.getFeatures().add(new LoggingFeature()); |
||||
|
return bus; |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package org.nl.acs.ext.wms.service.wsdl; |
||||
|
|
||||
|
import javax.jws.WebParam; |
||||
|
import javax.jws.WebService; |
||||
|
|
||||
|
@WebService(targetNamespace = "http://service.mrxu.com/") |
||||
|
public interface IWebServiceTest { |
||||
|
|
||||
|
String getDept(@WebParam(name = "jsonStr")String jsonStr); |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
package org.nl.acs.ext.wms.service.wsdl; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.cxf.Bus; |
||||
|
import org.apache.cxf.bus.spring.SpringBus; |
||||
|
import org.apache.cxf.jaxws.EndpointImpl; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.boot.ApplicationArguments; |
||||
|
import org.springframework.boot.ApplicationRunner; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.web.context.WebApplicationContext; |
||||
|
|
||||
|
|
||||
|
@Component |
||||
|
@Slf4j |
||||
|
public class PublishEndpoint implements ApplicationRunner { |
||||
|
|
||||
|
@Autowired |
||||
|
private WebApplicationContext applicationConnect; |
||||
|
|
||||
|
@Autowired() |
||||
|
@Qualifier(Bus.DEFAULT_BUS_ID) |
||||
|
private SpringBus bus; |
||||
|
|
||||
|
@SuppressWarnings("resource") |
||||
|
@Override |
||||
|
public void run(ApplicationArguments applicationArguments) throws Exception { |
||||
|
log.info("开始进行自动发布webService接口"); |
||||
|
|
||||
|
String[] beanNames = applicationConnect.getBeanNamesForAnnotation(AutoPublish.class); |
||||
|
for(String beanName : beanNames) { |
||||
|
String publishAddr = applicationConnect.getType(beanName).getAnnotation(AutoPublish.class).publishAddress(); |
||||
|
EndpointImpl endpoint = new EndpointImpl(bus, applicationConnect.getBean(beanName)); |
||||
|
endpoint.publish(publishAddr); |
||||
|
|
||||
|
log.info(String.format("发布接口地址:[%s]", publishAddr)); |
||||
|
} |
||||
|
|
||||
|
log.info("weBservice接口自动发布结束"); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package org.nl.acs.ext.wms.service.wsdl; |
||||
|
|
||||
|
public class Test { |
||||
|
|
||||
|
public static void Test(){ |
||||
|
System.out.println("1111"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package org.nl.acs.ext.wms.service.wsdl; |
||||
|
|
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.jws.WebService; |
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
@Service("WebServiceTest") |
||||
|
@AutoPublish(publishAddress = "ACS") |
||||
|
@WebService(endpointInterface = "org.nl.acs.ext.wms.service.wsdl.IWebServiceTest", |
||||
|
serviceName = "WebServiceTest", |
||||
|
targetNamespace = "http://127.0.0.1:8010/WebServiceTest/" |
||||
|
) |
||||
|
public class WebServiceTest implements IWebServiceTest { |
||||
|
|
||||
|
@Override |
||||
|
public String getDept(String jsonStr) { |
||||
|
return "111"; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue