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

  • 相关阅读:
    [Django]中间件
    Python装饰器的诞生过程-->和闭包的微妙关系
    Python实现经典算法之---斐波那契数列(兔子问题&走楼梯问题)
    二分查找---非递归算法和递归算法
    JavaScript的event对象
    input[type='submit']input[type='button']button等按钮在低版本的IE下面,去掉黑色边框的问题
    JavaScript 之 数据在内存中的存储和引用
    HTML5 之 简单汇总
    HTML5 Canvas——基础入门
    nodejs(14)express获取url中的参数
  • 原文地址:https://www.cnblogs.com/smallfa/p/15343293.html
Copyright © 2011-2022 走看看