CXF与Spring集成,配置webservice客户端,这里主要是调用上一章的webservice服务。
HelloWorld文件:
package
com.flyfox.service;
<wbr></wbr>
import
javax.jws.WebService;
<wbr></wbr>
@WebService
public
interface HelloWorld {
<wbr><wbr><wbr></wbr></wbr></wbr> String sayHi(String text);
}
HelloWorldClient文件:
package com.flyfox.client;
<wbr></wbr>
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationC<wbr>ontext;</wbr>
<wbr></wbr>
import com.flyfox.service.HelloWorld;
<wbr></wbr>
public class HelloWorldClient {
<wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr> private static Logger logger = Logger.getLogger(HelloWorldClient.class);</wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr> public static void main(String[] args) {</wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> logger.info("####################################################111");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> ApplicationContext context = new ClassPathXmlApplicationC<wbr>ontext("applicationContext-client.xml"); // your Spring ApplicationContext</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> logger.info("####################################################222");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> HelloWorld client = (HelloWorld) context.getBean("client",HelloWorld.class);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> logger.info("####################################################333");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> logger.info("client:"+client.sayHi("zhangsan"));</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr> }</wbr></wbr></wbr></wbr></wbr></wbr>
}
<wbr></wbr>
applicationContext-client.xml:
<?xml
version="1.0"
encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
<wbr><wbr><wbr></wbr></wbr></wbr>
xmlns:context="http://www.springframework.org/schema/context"
<wbr><wbr><wbr></wbr></wbr></wbr>
xmlns:jaxws="http://cxf.apache.org/jaxws"
<wbr><wbr><wbr></wbr></wbr></wbr>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<wbr><wbr><wbr></wbr></wbr></wbr>
xsi:schemaLocation="http://www.springframework.org/schema/beans
<wbr><wbr><wbr></wbr></wbr></wbr> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
<wbr><wbr><wbr></wbr></wbr></wbr> http://www.springframework.org/schema/context
<wbr><wbr><wbr></wbr></wbr></wbr> http://www.springframework.org/schema/context/spring-context-3.0.xsd
<wbr><wbr><wbr></wbr></wbr></wbr> http://cxf.apache.org/jaxws
<wbr><wbr><wbr></wbr></wbr></wbr> http://cxf.apache.org/schemas/jaxws.xsd">
<wbr><wbr><wbr></wbr></wbr></wbr>
<wbr><wbr><wbr></wbr></wbr></wbr>
<import
resource="classpath:META-INF/cxf/cxf.xml"/>
<wbr><wbr><wbr></wbr></wbr></wbr>
<import
resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<wbr><wbr><wbr></wbr></wbr></wbr>
<import
resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<wbr></wbr>
<wbr><wbr><wbr></wbr></wbr></wbr>
<!--
<wbr><wbr><wbr></wbr></wbr></wbr> <bean id="client" class="com.flyfox.service.HelloWorld"
<wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr> factory-bean="clientFactory" factory-method="create" />
<wbr></wbr>
<wbr><wbr><wbr></wbr></wbr></wbr> <bean id="clientFactory"
<wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr> class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr> <property name="serviceClass" value="com.flyfox.service.HelloWorld" />
<wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr> <property name="address"
<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> value="http://localhost:8080/CXFAndSpring/services/HelloWorld" />
<wbr><wbr><wbr></wbr></wbr></wbr> </bean>
<wbr></wbr><wbr><wbr> --></wbr></wbr>
<wbr><wbr><wbr></wbr></wbr></wbr>
<jaxws:client
id="client"<wbr></wbr>
serviceClass="com.flyfox.service.HelloWorld"
<wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
address="http://localhost:8080/CXFAndSpring/services/HelloWorld"/>
<wbr><wbr><wbr></wbr></wbr></wbr>
</beans>
分享到:
相关推荐
利用CXF3.0+Spring3.2 HelloWorld实例,并且导入了小量的jar包以及在写例子的过程中遇见的一些错误!
cxf+spring+tomcat 只是演示,一个helloWorld的例子
CXF整合spring,同时支持JSON和XML的CXF配置,支持自动转成实体类,其中的hibernate配置可以不用理会。如果还有不明白可以在留言里留下联系方式,大家可以一起讨论
cxf2.1.3 web项目Helloworld,在tomcat6.0可以跑,相关lib可以从cxf.apache.org下载.
NULL 博文链接:https://a52071453.iteye.com/blog/1675822
2.HelloWorld 3.WSDL描述 WebService CXF学习——进阶篇 1.SOAP讲解 2.JAX-WS讲解 3.对象传递 WebService CXF学习——高级篇(一)(二) 1.整合Spring框架 2.CXF+Spring+Hibernate 3.WS-Security ...
spring + cxf + restful + soap 方便初学者很快上手。 注解描述 @Path注解的值是一个相对的URI路径,这个路径指定了该Java类的位置,例如/helloworld。在这个URI中可以包含变量,例如可以获取用户的姓名然后作为参数...
webservice地址 http://localhost:8080/springCxf/HelloWorld?wsdl
这个版本是我上次传的CXF整合spring的加强版,增加了上传和下载已经拦截器的功能。如果还有不明白可以在留言里留下联系方式,大家可以一起讨论
Hello World Rest 使用 Apache Cxf 和 Spring Framework
创建合约第一个客户端和端点。 使用的一般项目设置工具: Apache CXF 3.2 Spring Boot 1.5 Maven 3.5 以下代码的组织方式使您可以选择仅运行客户端(消费者)或端点(提供者)部分。 在示例中,我们将设置这两个部分...
收藏的CXF入门文档…………. CXF与spring集成 cxf+spring+struts2的helloWorld
cxf学习笔记.详细的描述了我学习cxf的过程.服务端采用 cxf+spring的...1:最简单的hello world 2:集合类的传输 3:大数据的传输(上传下载) 4:安全性 4.1:用户令牌 4.2:数字签名 4.3:报文加密 4.4:混合认证
CXF(服务器正常)(创建客户端) Spring 4(弹簧安全性)XStream (ok) Pom 模块React? Bootstrap () Spring boot(呃,不适用于我想控制所有的大型应用程序......)TestDrivenDevelopment Mikroservisy Strust.......
Cxf自动发布WebService(不使用Spring),包含架包,无需配置,直接访问/cxfService/ws/helloWorld?wsdl
一个java webService项目,使用spring / mybatis / apache cxf。 1个数据库配置 修改文件:src \ main \ resources \ application.properties。 该项目包含oracle jdbc,如果需要其他,则应添加jdbc lib。 2 mybatis...