zoukankan      html  css  js  c++  java
  • 学习webservice之cxf(1):使用cxf实现webservice(使用jdk1.8)

    maven代码:

      <dependencies>
          <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.2.5</version>
        </dependency>
          <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-core</artifactId>
            <version>3.2.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>3.2.5</version>
        </dependency>
      </dependencies>

     Server代码:

    package com.rg2.webservice.impl;
    
    import javax.xml.ws.Endpoint;
    
    import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
    
    import com.rg2.webservice.HelloWorld;
    
    public class Server {
    
        public static void main(String[] args) {
            System.out.println("web service start");
            HelloWorld implementor = new HelloWorldImpl();
            String address = "http://localhost/helloWorld";
    //        Endpoint.publish(address, implementor);//jdk实现暴露webservice接口
            JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
            factoryBean.setAddress(address);//设置暴露地址
            factoryBean.setServiceClass(HelloWorld.class);//接口类
            factoryBean.setServiceBean(implementor);//设置实现类
            factoryBean.create();//创建webservice接口
            System.out.println("web service started");
        }
    
    }
  • 相关阅读:
    PAT 1059. Prime Factors
    PAT 1058. A+B in Hogwarts
    关于树状数组
    PAT 1057. Stack
    PAT 1056. Mice and Rice
    PAT 1055. The World's Richest
    PAT 1054. The Dominant Color
    fft_filter  designed to filter gridded data in an a
    matlab 1 yr oscillations
    RMVANNUAL
  • 原文地址:https://www.cnblogs.com/zhengyuanyuan/p/9265628.html
Copyright © 2011-2022 走看看