CXF-HelloWorld-Java first 使用注释方式

来源:互联网 发布:mac怎么查激活时间 编辑:程序博客网 时间:2024/06/05 14:10

接口 HelloWorld

 

package com.demo;

 

import javax.jws.WebService;

 

@WebService

 

public interface HelloWorld {


 public String sayHi();


}

 

 

HelloWorldImpl.java  实现接口类


package com.demo;

 

import javax.jws.WebService;

 

@WebService(
  endpointInterface="com.demo.HelloWorld",//端点接口名称
  serviceName="com.demo.helloWorld")  //服务名称

 

public class HelloWorldImpl implements HelloWorld {

 

 public String sayHi() {


  // TODO Auto-generated method stub
  return "Hello";
 }


}

 

Server类:

package com.demo;

 

import javax.xml.ws.Endpoint;

 

public class Server {


    protected Server() throws Exception {

          System.out.println("Starting Server");

          HelloWorldImpl implementor = new HelloWorldImpl();

          String address = "http://localhost:9000/helloWorld";

          Endpoint.publish(address, implementor);

     }

 

     public static void main(String args[]) throws Exception {

         new Server();

         System.out.println("Server ready...");

         Thread.sleep(5 * 60 * 1000);

         System.out.println("Server exiting");

         System.exit(0);

     }
}

访问http://localhost:9000/helloWorld?wsdl

原创粉丝点击