为什么第一次访问http://localhost:8080/cxf-web-server/service有点慢?证明第一次访问的时候CXFServlet被初始化了被加载了.一般是让CXFServlet随着服务器启动的时候加载,而不让它进行访问的时候加载.如果改成启动的时候加载CXFServlet就变成启动服务器的时候慢了.

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
package com.rl.cxf.web.client;

import com.rl.web.server.HelloService;
import com.rl.web.server.HelloServiceService; public class WebClient {
public static void main(String[] args) {
HelloServiceService hss = new HelloServiceService();
HelloService hs = hss.getHelloServicePort();
String result = hs.sayHello("李四");
System.out.println(result);
}
}
package com.rl.web.server;

import javax.jws.WebService;

import org.springframework.web.context.ContextLoaderListener;

@WebService //所有的webservice服务类都要加@webservice,接口的形式加在接口上

public class HelloService {
public String sayHello(String name){
//ContextLoaderListener
return name + " hello";
}
}
<?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:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<!-- 引入CXF Bean定义如下,早期的版本中使用 -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<!--
address:tomcat的host http://ip:port/projectName/service/后面的一端路径
implementor:指定具体的服务的类
-->
<jaxws:endpoint id="hello" address="/hello" implementor="com.rl.web.server.HelloService">
<!-- 输入拦截器,打印输入的消息 -->
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>
</jaxws:outInterceptors>
</jaxws:endpoint>
</beans>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- 使用Spring的监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class><!-- 初始化Spring的容器,cxf.xml本身就是一个Spring的容器.可以把cxf.xml作为Spring的容器进行加载. -->
<!-- 能加载Spring文件的类,这个类叫什么? -->
</listener>
<context-param>
<param-name>contextConfigLocation</param-name><!-- param-name不能再指定config-location,而是要指定ContextLoaderListener里面读取Spring文件的那个Key -->
<param-value>classpath:cxf.xml</param-value>
</context-param>
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<!--
<init-param>
<param-name>config-location</param-name>
<param-value>classpath:cxf.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
-->
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/service/*</url-pattern> <!-- 拦截这种请求 -->
</servlet-mapping>
</web-app>
<?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:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<!-- 引入CXF Bean定义如下,早期的版本中使用 -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<!--
address:tomcat的host http://ip:port/projectName/service/后面的一端路径
implementor:指定具体的服务的类
-->
<jaxws:endpoint id="hello" address="/hello" implementor="com.rl.web.server.HelloService">
<!-- 输入拦截器,打印输入的消息 -->
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>
</jaxws:outInterceptors>
</jaxws:endpoint>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 使用Spring的监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class><!-- 初始化Spring的容器,cxf.xml本身就是一个Spring的容器.可以把cxf.xml作为Spring的容器进行加载. -->
<!-- 能加载Spring文件的类,这个类叫什么? -->
</listener>
<context-param>
<param-name>contextConfigLocation</param-name><!-- param-name不能再指定config-location,而是要指定ContextLoaderListener里面读取Spring文件的那个Key -->
<param-value>classpath:cxf.xml</param-value>
</context-param>
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<!--
<init-param>
<param-name>config-location</param-name>
<param-value>classpath:cxf.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
-->
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/service/*</url-pattern> <!-- 拦截这种请求 -->
</servlet-mapping>
</web-app>

day63-webservice 07.07.如何修改cxf配置文件路径的更多相关文章

  1. 几种流行的开源WebService框架Axis1,Axis2,Xfire,CXF,JWS比较

    几种流行的开源WebService框架Axis1,Axis2,Xfire,CXF,JWS比较 来源   XFire VS Axis XFire是与Axis2 并列的新一代WebService平台.之所 ...

  2. 分布式架构探索 - 2. WebService RPC框架之Apache CXF

    Apache CXF是一个开源的WebService RPC框架. 例子: 1. 新建一个maven web项目, 添加pom 如下: <?xml version="1.0" ...

  3. WebService技术(二)— CXF

    前言:学习笔记,以供参考 Apache CXF 是一个开源的 Services 框架,CXF 帮助您利用 Frontend 编程 API 来构建和开发 Services .可以与Spring进行快速无 ...

  4. 3.SpringMVC修改配置文件路径和给界面传递数据

    1.修改配置文件路径  达到  配置多文件的目的 web.xml文件中基础配置有springMVC配置的servlet路径 <servlet-name>SpringMVC</serv ...

  5. asp.net中为什么修改了配置文件后我们不需要重启IIS

    本文转载:http://blog.itpub.net/12639172/viewspace-659819/ 大家知道,asp.net中,如果我们修改了配置文件只要把它保存之后,就会立刻反应到程序中, ...

  6. Spark添加/更改集群节点需要修改的配置文件

    笔记:在配置好了spark后,如果需要添加/删除一个结点需要修改如下配置文件 cd $HADOOP/etc/hadoop 进入hadoop配置文件夹下 修改 slaves,将对应的节点添加/删除 修改 ...

  7. sublime text3修改默认配置文件是失败的解决方法

    如果你修改sublime text3的默认配置文件Preferences.sublime-settings失败,现实的错误信息如下图: 其实根据提示信息就好找问题出在哪里了:权限 要想成功的修改默认配 ...

  8. Android Studio配置文件路径修改

    用Android Studio进行Android开发已经成为趋势了,好的工具要用得称手也少不了好的调教,在Windows下更是如此.这里对Android Studio的相关配置文件的路径修改做下小结. ...

  9. Apache修改了配置文件中的路径后,登录该地址网页出现问题 (其中介绍了selinux的域和安全上下文)

    默认的网站数据存放在: /var/www/html 首页名称: index.html Apache服务程序的主配置文件: /etc/httpd/conf/httpd.conf (若是将  119  行 ...

随机推荐

  1. JavaScript中比较运算符的使用

    比较运算符的基本操作过程是:首先对操作数进行比较,这个操作数可以是数字也可以是字符串,然后返回一个布尔值true或false. 在JavaScript中常用的比较运算符如下表所示. 例如,某商场店庆搞 ...

  2. System.DateTime.Now 24小时制。

    this.Label6.Text = "当前时间:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") ...

  3. 省市区县的sql语句——区县

    DROP TABLE IF EXISTS `area`; CREATE TABLE `area` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `code` va ...

  4. ★Java语法(四)——————————运算符

    使用除法“/”  ,要特别注意数据类型的问题.若被除数和除数都是整形,且被除数不能被除数整除时,这时输出的结果为整数,(即整形数/整形数=整形数),这是因为整形变量无法保存小数点后面的数据所致,要特别 ...

  5. IE浏览器发展史

  6. Python语言之常用函数

    1.input(),raw_input() input() = eval( raw_input() ) 其中raw_input()将所有的输入当做字符串处理. eval(str [,globals [ ...

  7. BZOJ 1864: [Zjoi2006]三色二叉树 树形DP + 读入

    Description Input 仅有一行,不超过500000个字符,表示一个二叉树序列. Output 输出文件也只有一行,包含两个数,依次表示最多和最少有多少个点能够被染成绿色. 题解:本题大水 ...

  8. PAT_A1105#Spiral Matrix

    Source: PAT A1105 Spiral Matrix (25 分) Description: This time your job is to fill a sequence of N po ...

  9. vue-cli index.js dev 配置中 assetsPublicPath 的值不能填 "./" 的问题

    问题 使用nginx又代理了一层 在浏览器中 / 代表域名的根目录,./代表当前路径 线上发布的时候一般都会使用nginx反向代理,所以使用./是最靠谱的,但是vue-cli dev 中的 asset ...

  10. RF学习使用记录【4】

    四 Extending Robot Framework 4.1 Creating test libraries RF的测试能力由测试库支持决定,已经有许多的测试库,有一些随着RF框架安装,但是更多的需 ...