课程计划

1、 webService入门(了解)

2、 基于jdk1.7开发webservice服务(了解)

3、 Apache CXF框架入门(掌握)

4、 基于CXF框架搭建CRM系统(掌握)

1.1 wsdl  webservice描述/定义语言

俗称“web服务使用说明书

 

 

网络服务描述/定义语言:每一个webservice服务都有自己wsdl

wsdl是标准xml文件,wsdl(xml文件)包含服务名称,服务中包含方法名方法参数(参数类型),方法返回类型

 

通过jdk提供命令wsimport,解析wsdl(本质就是xml文件),生成客户端java调用代码(生成代码方法名称,方法参数,方法返回类型)。

 

WSDL地址:服务地址+?WSDL

 SOAP =html+xml;

SOAP :简单对象访问协议,规定了WebService远程调用传输的xml数据格式.

CXF一个小demo

通过spring工厂产生代理对象;

1、 创建新的工程

2、 将cxf的相关jar包到入项目

3、 提供cxf配置文件:spring配置文件

4、 只需要拷贝生成的服务接口到项目中,在cxf配置文件中进行配置

 

基于cxf搭建CRM项目环境

 

CRM系统只是为了提供webservice服务供其他两个项目:后台管理系统,前台系统调用;没有提供客户数据维护页面;

 

CRM项目中使用技术:spring+spring-data-jpa +CXF +oracle数据库

 

1、 创建maven project  父工程为:common_parent

1.1.1 CRM框架环境

Spring+spring-data-jpa+CXF

 

1、 搭建spring环境

a) 配置文件:applicationContext.xml

b) Web.xml配置监听器

2、 Spring整合jpa

3、 Spring-data-jpa  :2,3配置去复制bos_web项目下  注意:包扫描路径改为crm

?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:aop="http://www.springframework.org/schema/aop"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:jdbc="http://www.springframework.org/schema/jdbc"

xmlns:jaxws="http://cxf.apache.org/jaxws"

xmlns:soap="http://cxf.apache.org/bindings/soap"

xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:jpa="http://www.springframework.org/schema/data/jpa"

xmlns:task="http://www.springframework.org/schema/task"

xsi:schemaLocation="

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd

http://www.springframework.org/schema/data/jpa

http://www.springframework.org/schema/data/jpa/spring-jpa.xsd

http://cxf.apache.org/bindings/soap

http://cxf.apache.org/schemas/configuration/soap.xsd

http://cxf.apache.org/jaxws

http://cxf.apache.org/schemas/jaxws.xsd">

1、 服务端CXF环境

a) Web.xml配置servlet

<!-- 配置cxfServlet 处理客户端请求 -->

<servlet>

<servlet-name>cxf</servlet-name>

<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>

<!--    <init-param>之前通过初始化参数加载spring配置文件,发布服务;现在已经配置监听器</init-param> -->

</servlet>

<servlet-mapping>

<servlet-name>cxf</servlet-name>

<url-pattern>/service/*</url-pattern>

</servlet-mapping>

5、Web.xml

<!-- spring的监听器 -->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:applicationContext.xml</param-value>

</context-param>

<!-- cxfServlet:处理客户端请求  2、发布服务 -->

<servlet>

<servlet-name>cxf</servlet-name>

<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>cxf</servlet-name>

<url-pattern>/service/*</url-pattern>

</servlet-mapping>

Web.xml

<!-- spring的监听器 -->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:applicationContext.xml</param-value>

</context-param>

<!-- cxfServlet:处理客户端请求  2、发布服务 -->

<servlet>

<servlet-name>cxf</servlet-name>

<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>cxf</servlet-name>

<url-pattern>/service/*</url-pattern>

</servlet-mapping>

1.1 实现案例

1、 创建服务接口,在接口上使用注解@WebService,创建实现类

 

 

2、 Cxf配置文件中,配置webservice服务端对象

 

3、 启动项目:查询webservice服务

Wsdl地址:服务地址+?wsdl

1、 完善服务端查询所有客户方法

a) 创建dao继承jparepository

b) 将dao对象注入service中

1.1 bos调用服务户端CRM方法

1、 获取wsdl地址:http://localhost:8082/bos_crm/service/customer?wsdl  生成代码 通过jdk命令 wsimport

 

2、 将接口拷贝到bos-service项目中

1、 在客户端spring配置文件中,配置客户端调用对象

1、 在需要调用CRM的代码中注入客户端对象

项目一:第六天 WebService写接口 和CXF框架的更多相关文章

  1. WebService通讯技术的CXF框架问题

    WebService通讯技术的CXF框架问题 严重: Servlet /cxf_rs_spring threw load() exception java.lang.ClassCastExceptio ...

  2. JAVAEE——BOS物流项目07:WebService入门、apache CXF入门、基于CXF发布CRM服务

    1 学习计划 1.WebService入门 n 什么是WebService n 调用网络上的WebService服务 n SOAP和WSDL概念 n 基于JDK1.7发布一个简单的WebService ...

  3. webservice的简单使用,cxf框架的的使用

    Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和配置这些应用程序,用于开发分布 ...

  4. webservice第三篇【接口开发webservice、CXF框架使用、IDEA下使用webservice、小例子】

    实现接口的webservice 服务端 import javax.jws.WebService; /**面向接口的webservice发布方式 * * */ @WebService public in ...

  5. (二)使用CXF开发WebService服务器端接口

    CXF作为java领域主流的WebService实现框架,Java程序员有必要掌握它. CXF主页:http://cxf.apache.org/ 简介:百度百科 今天的话,主要是用CXF来开发下Web ...

  6. java web项目(spring项目)中集成webservice ,实现对外开放接口

    什么是WebService?webService小示例 点此了解 下面进入正题: Javaweb项目(spring项目)中集成webservice ,实现对外开放接口步骤: 准备: 采用与spring ...

  7. WebService之CXF框架

    本文主要包括以下内容 ant工具的使用 利用cxf实现webservice cxf与spring整合 ajax访问webservice ant 工具 1.为什么要用到ant这个工具呢? Ant做为一种 ...

  8. 基于CXF框架下的SOAP Webservice服务端接口开发

    最近对webservice 进行入门学习,网上也是找了很多的学习资料.总得感觉就是这了解点,那了解点.感觉不够系统,不够容易入门.差不多断断续续看了一个星期了,今天小有成果,把客户端,服务端都搞定了. ...

  9. 如何在SpringMVC项目中部署WebService服务并打包生成客户端

    场景 某SpringMVC项目原本为一个HTTP的WEB服务项目,之后想在该项目中添加WebService支持,使该项目同时提供HTTP服务和WebService服务.其中WebService服务通过 ...

随机推荐

  1. [原创]Scala学习:函数的定义

    方式一:标准的定义函数 def 函数名(参数1: 参数类型,参数2: 参数类型): 返回值类型 = { 函数体 } 例子 def max(x: Int,y: Int): Int ={ if(x > ...

  2. linux 资源管理

    1. 查看内存信息  free [root@rhel6 script]# free total used free shared buffers cached Mem: -/+ buffers/cac ...

  3. 多种方法求java求整数的位数

    方法一 private static int getNumLenght(long num){ num = num>0?num:-num; return String.valueOf(num).l ...

  4. 现有exe转为服务_方式01

    1.安装X.exe服务: ...>路径\X.exe /install 2.卸载X.exe服务: ...>路径\X.exe /uninstall 3.开始运行XX(程序是X.exe,服务名是 ...

  5. Windows默认字符集_查询

    https://zhidao.baidu.com/question/32462047.html Windows95. XP……7操作系统自带的都是GBK字符集(含2万余汉字),是完全兼容GB2312( ...

  6. html转义字符及css清除

    1. [代码][Java]代码     ​import java.util.HashMap;import java.util.Map; import org.apache.commons.lang3. ...

  7. 修改myEclipse2014web项目名称

    重命名项目名称后 右键点击你的项目,然后选择属性---->然后点击myeclipse—>Project Facets—> web 选项,修改web context-root名称为你要 ...

  8. adb命令(一)

    针对移动端 Android 的测试, adb 命令是很重要的一个点,必须将常用的 adb 命令熟记于心, 将会为 Android 测试带来很大的方便,其中很多命令将会用于自动化测试的脚本当中. And ...

  9. L105

    A pill could soon radio signals from inside your gut to help doctors diagnose diseases from ulcers t ...

  10. BEC listen and translation exercise 31

    听力练习: All societies have ways of encouraging and enforcing what they view as appropriate behaviour w ...