webService 可以将应用程序转换成网络应用程序。是简单的可共同操作的消息收发框架。

基本的webService平台是 XML 和 HTTP。

      HTTP 是最常用的互联网协议;

      XML 是 webService 的基础,因为可以用于不同平台和编程语言之间。

webService平台的元素:

       SOAP(简易对象访问协议);

       UDDI(通用描述、发现、整合);

       WSDL(web service 描述语言);

webService 有两种类型的应用

      1)可重复使用的应用程序组件:有些功能是不同应用程序常常用到的,比如:天气预报。webService可以把应用程序组件当做服务来提供;

      2)连接现有软件:通过为不同程序提供一种链接其数据的途径,解决协同办公的问题。

简单程序:

创建一个service 的 web service project工程 :

package com.service;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService   //将类标注为webService
public class Test {
    
    @WebMethod  //标注客户端调用的方法
    public String getString (String name){
        return name.toUpperCase();
    }
    public static void main(String[] args) {

   //发布到服务端 参数1:网络协议+ip+端口号(不能被占用)+上下文根+调用方法  参数2:new一个本类的实例
        Endpoint.publish("http://localhost:8085/Test", new Test());

   //标志着编译成功结束 可不写
        System.out.println("OK");
    }
}

//配置文件我现在还没有搞明白  如果不配配置测试地址就无响应

配置一个xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<!-- 注册组件扫描器 -->
    <context:component-scan base-package="com.service" />
</beans>

测试地址:http://localhost:8085/Test?wsdl

利用 webService soapUI 4.5.2软件 链接http://localhost:8085/service/Test 自动生成应用服务

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:getString>
         <!--Optional:-->
         <arg0>yyyy</arg0>  //<arg0>?</arg0> 原始显示是? 为需求参数
      </ser:getString>
   </soapenv:Body>
</soapenv:Envelope>

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:getStringResponse xmlns:ns2="http://service.com/">
         <return>YYYY</return>  //<return>?</return> 原始显示是? 为处理结果
      </ns2:getStringResponse>
   </S:Body>
</S:Envelope>


2、命令提示窗口执行生成命令。

先创建一个client 的web service project 工程

打开 命令窗口 输入

格式:wsimport -s "src目录" -p “生成类所在包名” -keep “wsdl发布地址”

    1)"src目录"地址不可含空格

    2)“wsdl发布地址”不要漏了“?wsdl”

效果:

  wsimport -s E:\WorkSpace\maven\client\src  -p com.client -keep http://localhost:8085/Test?wsdl
  正在解析 WSDL...
  正在生成代码...
  正在编译代码...

刷新项目就可以看到生成的client代码

但是client 客户端代码会有乱码问题目前还没有解决

最新文章

  1. SQL SERVER 重组含有特殊字符的索引时遇到&ldquo;关键字 'with' 附近有语法错误.&rdquo;
  2. windows下安装xgboost
  3. asp获取虚拟目录根路径
  4. addslashes() 函数和stripslashes()函数
  5. iOS之UI--关于modal
  6. 最新13个加速 Web 开发的框架和工具
  7. MyBatis之八:需要说明的几个java api的生命周期以及封装
  8. [原创] CSS总结!! 有关HTML第二篇 !!
  9. 找不到 com.google.zxing.ResultMetadataType 异常解决
  10. Python爬虫从入门到放弃(十九)之 Scrapy爬取所有知乎用户信息(下)
  11. Linux文件系统的层级结构
  12. File文件的读写操作RandomAccessFile类
  13. iOS逆向开发(6):微信伪造位置
  14. webpack的知识内容
  15. &lt;20190106&gt;千兆 小型局域网传输速率不达标问题解决
  16. sqli-labs less 1-4
  17. python中常用的模块一
  18. 2018.4.2 sqlite优化
  19. Python gevent
  20. .net framework 类库中必须掌握的命名空间(或者类)

热门文章

  1. JVM即时编译(JIT)
  2. JRobin绘制指定时间段的流量图
  3. 数据结构之---C语言实现图的邻接表存储表示
  4. [DB][MySql]关于取得自增字段的值、及@@IDENTITY 与并发性问题
  5. pymysql 本地不抱错 连接云数据库报错
  6. LeetCode241——Different Ways to Add Parentheses
  7. Batch基本知识
  8. strok函数用法【转】
  9. Coursera Algorithms week4 基础标签表 练习测验:Inorder traversal with constant extra space
  10. setings.py配置文件详解