zoukankan      html  css  js  c++  java
  • WebSevice<1> 发布 JDK12 <-> 20210927

    1、POM.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mayikt</groupId>
    <artifactId>mayikt_webservice</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
    <maven.compiler.source>12</maven.compiler.source>
    <maven.compiler.target>12</maven.compiler.target>
    </properties>
    <dependencies>
    <!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
    <dependency>
    <groupId>javax.jws</groupId>
    <artifactId>javax.jws-api</artifactId>
    <version>1.1</version>
    </dependency>
    <dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-ri</artifactId>
    <version>2.3.0</version>
    <type>pom</type>
    </dependency>
    <dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
    </dependency>
    </dependencies>

    </project>



    2、Sevice
    package com.mayikt.service;
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    import javax.xml.ws.Endpoint;


    @WebService
    public class UserService {


    @WebMethod
    public String getUser(long userId){
    return "mayikt nbnb"+userId;
    }

    public static void main(String[] args) {
    //定义WebService的发布地址,这个地址就是提供给外界访问Webervice的URL地址,URL地址格式为:http://ip:端口号/xxxx
    //String address = "http://192.168.1.100:8989/";这个WebService发布地址的写法是合法的
    //String address = "http://192.168.1.100:8989/Webservice";这个WebService发布地址的是合法的
    String address = "http://127.0.0.1:8989/service/UserService";
    //使用Endpoint类提供的publish方法发布WebService,发布时要保证使用的端口号没有被其他应用程序占用
    Endpoint.publish(address , new UserService());
    System.out.println("发布webservice成功!");
    }
    }





       3、发布

     public static void main(String[] args) {
    //定义WebService的发布地址,这个地址就是提供给外界访问Webervice的URL地址,URL地址格式为:http://ip:端口号/xxxx
    //String address = "http://192.168.1.100:8989/";这个WebService发布地址的写法是合法的
    //String address = "http://192.168.1.100:8989/Webservice";这个WebService发布地址的是合法的
    String address = "http://127.0.0.1:8989/service/UserService";
    //使用Endpoint类提供的publish方法发布WebService,发布时要保证使用的端口号没有被其他应用程序占用
    Endpoint.publish(address , new UserService());
    System.out.println("发布webservice成功!");
    }




     

    参考:https://www.cnblogs.com/xdp-gacl/p/4259481.html

  • 相关阅读:
    复制带有random指针的单链表
    loadrunner常见问题
    【转】性能测试、负载测试、压力测试的区别
    文件存储结构inode与RAM结构建立联系
    inode表元数据,存储在物理存储体上
    debug宏起作用应用
    linux内核常用函数或宏
    file、inode在应用层和驱动层之间的联系_转
    内核交互--sysfs
    内核交互--procfs
  • 原文地址:https://www.cnblogs.com/smallfa/p/15343293.html
Copyright © 2011-2022 走看看