好了,继续学习CXF WebService!这次学习CXF拦截器,老天开眼了,比较顺利,各位大牛,大神请飘过!不要嘲笑我等小白,不对我是老白了,因为我们不在一个频道上!首先还是要介绍一下开发工具和开发环境,jdk1.6.0_43+Tomcat6.0.29+MyEclipse10.5,没有使用Maven进行管理!
一、新建web工程,不要选择Java EE6.0,如果选了,会报一个错误!下面将会有介绍。
二、新建接口HelloWorld.java
package com.firstws.test;
import javax.jws.WebService;
@WebService
public interface HelloWorld{
public String sayHi(String name);
}
三、新建HelloWorldImpl.java
package com.firstws.test;
import javax.jws.WebService;
@WebService(endpointInterface = "com.firstws.test.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
//注意此处不能写@Override,好像是jdk1.5不支持
public String sayHi(String text) {
System.out.println("sayHi方法被调用!");
return "Hello " + text;
}
}
四、建立服务类Server.java
package com.firstws.test;
import javax.xml.ws.Endpoint;
public class Server {
protected Server() throws Exception {
System.out.println("Starting Server");
HelloWorldImpl implementor = new HelloWorldImpl();
String address = "http://localhost:8080/wbInter";
Endpoint.publish(address,implementor);
}
public static void main(String args[]) throws Exception {
new Server();
System.out.println("Server ready...");
Thread.sleep(5 * 60 * 1000);
System.out.println("Server exiting");
System.exit(0);
}
}
五、点击运行Server.java,如果新建web工程,你选择的是Java EE5.0,那么控制台将出现如下信息
Starting Server
2016-1-6 9:34:47org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBeanbuildServiceFromClass...
Server ready...
=====================================================================
如果你新建web工程是你选择的是Java EE6.0,那么控制台将报如下异常!然后网上一搜好多解决方式,巴拉巴拉,心中一万头草你妈飘过~~~,最后发现是工程中的jdk问题~~~~
Starting Server
2016-1-6 9:37:10 ...
Exception in thread"main" java.lang.NoSuchMethodError:org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
atorg.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607)
atorg.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431)
atorg.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69)
atorg.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:204)
atorg.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:74)
atorg.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.addServant(JettyHTTPServerEngine.java:417)
atorg.apache.cxf.transport.http_jetty.JettyHTTPDestination.activate(JettyHTTPDestination.java:179)
atorg.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:53)
atorg.apache.cxf.binding.AbstractBindingFactory.addListener(AbstractBindingFactory.java:95)
atorg.apache.cxf.binding.soap.SoapBindingFactory.addListener(SoapBindingFactory.java:895)
atorg.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:123)
atorg.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:362)
atorg.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
atorg.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:155)
atjavax.xml.ws.Endpoint.publish(Endpoint.java:57)
atcom.firstws.test.Server.<init>(Server.java:11)
atcom.firstws.test.Server.main(Server.java:15)
六、建立一个拦截器测试类InterceperTest.java
package com.firstws.interceptor;
importorg.apache.cxf.interceptor.LoggingInInterceptor;
importorg.apache.cxf.interceptor.LoggingOutInterceptor;
importorg.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import com.firstws.test.HelloWorld;
public class InterceperTest {
publicstatic void main(String[] args) {
JaxWsProxyFactoryBeanfactory = new JaxWsProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:8080/wbInter/HelloWorld");
factory.getInInterceptors().add(newLoggingInInterceptor());
factory.getOutInterceptors().add(newLoggingOutInterceptor());
HelloWorldhw = (HelloWorld) factory.create();
Stringresult = hw.sayHi("abc");
System.out.println("haaha=="+result);
}
}
七、点击运行InterceperTest.java
信息: Outbound Message
---------------------------
ID: 1
Address:http://localhost:8080/wb2/HelloWorld
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*],SOAPAction=[""]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayHixmlns:ns2="http://test.firstws.com/"><arg0>abc</arg0></ns2:sayHi></soap:Body></soap:Envelope>
--------------------------------------
2016-1-6 9:41:18org.apache.cxf.services.HelloWorldService.HelloWorldPort.HelloWorld
信息: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type:text/xml;charset=UTF-8
Headers: {Content-Length=[211],content-type=[text/xml;charset=UTF-8], Server=[Jetty(8.1.15.v20140411)]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayHiResponsexmlns:ns2="http://test.firstws.com/"><return>Helloabc</return></ns2:sayHiResponse></soap:Body></soap:Envelope>
--------------------------------------
haaha==Hello abc
八、有些时候我们需要自定义一个拦截器,做一些特殊的处理!新建一个实现类
MessageInterceptor.java
package com.firstws.interceptor;
importorg.apache.cxf.interceptor.Fault;
importorg.apache.cxf.message.Message;
importorg.apache.cxf.phase.AbstractPhaseInterceptor;
/**
* 功能:自定义消息拦截器
* 作者:张述飞
* 创建日期:2015-12-31 9:55
* qq:361202421
* 版本:V1.0
*/
Public class MessageInterceptorextends AbstractPhaseInterceptor<Message> {
publicMessageInterceptor(String phase) {
super(phase);
}
publicvoid handleMessage(Message message) throws Fault {
System.out.println("###########handlerMessage############");
System.out.println(message);
if(message.getDestination() != null) {
System.out.println(message.getId()+ "##" +message.getDestination().getMessageObserver());
}
if(message.getExchange() != null) {
System.out.println(message.getExchange().getInMessage()+ "##" +message.getExchange().getInFaultMessage());
System.out.println(message.getExchange().getOutMessage()+ "##" +message.getExchange().getOutFaultMessage());
}
}
}
九、新建发布类DeployInteceptorClient.java
package com.firstws.interceptor;
importorg.apache.cxf.jaxws.JaxWsServerFactoryBean;
importorg.apache.cxf.phase.Phase;
importcom.firstws.test.HelloWorld;
importcom.firstws.test.HelloWorldImpl;
public class DeployInteceptorClient{
publicstatic void main(String[] args) throws Exception {
JaxWsServerFactoryBeanfactory = new JaxWsServerFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:8080/wbInter/HelloWorld");
factory.setServiceBean(newHelloWorldImpl());
factory.getInInterceptors().add(newMessageInterceptor(Phase.RECEIVE));
factory.getOutInterceptors().add(newMessageInterceptor(Phase.SEND));
factory.create();
System.out.println("Serverstart ~~~~~");
Thread.sleep(5*1000*60);
System.exit(0);
System.out.println("Serverexit~~~");
}
}
十、运行DeployInteceptorClient.java,运行结果为
Server start ~~~~~
十一、 新建HelloWorldServiceClient.java类
package com.firstws.interceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
importcom.firstws.test.HelloWorld;
public classHelloWorldServiceClient {
/**
* @param args
*/
publicstatic void main(String[] args) {
JaxWsProxyFactoryBeanclient = new JaxWsProxyFactoryBean();
client.setServiceClass(HelloWorld.class);
client.setAddress("http://localhost:8080/wbInter/HelloWorld");
HelloWorldservice = (HelloWorld) client.create();
System.out.println("[result]"+service.sayHi("张述飞"));
}
}
十二、 运行HelloWorldServiceClient.java,客户端运行结果为
[result]Hello 张述飞
服务端运行结果是
Server start ~~~~~
###########handlerMessage############
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={Accept=[*/*],Cache-Control=[no-cache], connection=[keep-alive], Content-Length=[191],content-type=[text/xml; charset=UTF-8],
~~~~~
Content-Type=text/xml;charset=UTF-8}##null
null##null
sayHi方法被调用!
###########handlerMessage############
{javax.xml.ws.wsdl.port={http://test.firstws.com/}HelloWorldPort,org.apache.cxf.ws.policy.EffectivePolicy=org.apache.cxf.ws.policy.EffectivePolicyImpl@151ac10,
org.apache.cxf.service.model.BindingMessageInfo=org.apache.cxf.service.model.BindingMessageInfo@f77511,Content-Type=text/xml, org.apache.cxf.message.Message.RESPONSE_CODE=200,org.apache.cxf.headers.Header.list=[]}##null
=====================================================================
到这里为止,基本上的拦截器已经做完了,下面这部分将是和Spring嵌套使用了!!
十三、 下面这部分引用的是(达拉斯母牛的CXF实战之自定义拦截器(五)),博客地址:http://blog.csdn.net/accountwcx/article/details/47147831
在这里先谢谢他的分享!!如果侵犯了你的权益,请告诉我,我撤下来!
十四、 权限认证拦截器处理SOAPHeader中的认证信息,客户端在发起请求时在SOAPHeader中添加认证信息,服务端在接收到请求后,校验认证信息,校验通过则继续执行,校验不通过则返回错误。
<!-- 认证信息格式如下 -->
<auth xmlns="http://localhost:8080/auth">
<name>admin</name>
<password>admin</password>
</auth>
十五、 客户端代码AuthAddInterceptor.java
package com.firstws.spring;
import java.util.List;
import javax.xml.namespace.QName;
importorg.apache.cxf.binding.soap.SoapMessage;
importorg.apache.cxf.headers.Header;
importorg.apache.cxf.helpers.DOMUtils;
importorg.apache.cxf.interceptor.Fault;
importorg.apache.cxf.phase.AbstractPhaseInterceptor;
importorg.apache.cxf.phase.Phase;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class AuthAddInterceptorextends AbstractPhaseInterceptor<SoapMessage> {
publicAuthAddInterceptor() {
super(Phase.PREPARE_SEND);
}
publicvoid handleMessage(SoapMessage message) throws Fault {
List<Header>headers = message.getHeaders();
Documentdoc = DOMUtils.createDocument();
Elementauth = doc.createElementNS("http://zhangshufei/auth","auth");
Elementname = doc.createElement("name");
name.setTextContent("admin");
Elementpassword = doc.createElement("password");
password.setTextContent("admin");
auth.appendChild(name);
auth.appendChild(password);
headers.add(newHeader(new QName(""),auth));
}
}
十六、 验证代码AuthValidateInterceptor.java
package com.firstws.spring;
import java.util.List;
import javax.xml.namespace.QName;
importorg.apache.cxf.binding.soap.SoapMessage;
importorg.apache.cxf.headers.Header;
import org.apache.cxf.interceptor.Fault;
importorg.apache.cxf.phase.AbstractPhaseInterceptor;
importorg.apache.cxf.phase.Phase;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public classAuthValidateInterceptor extends AbstractPhaseInterceptor<SoapMessage> {
publicAuthValidateInterceptor() {
super(Phase.PRE_INVOKE);
}
publicvoid handleMessage(SoapMessage message) throws Fault {
System.out.println("哈哈开始验证了!");
List<Header>headers = message.getHeaders();
if(headers == null || headers.size() < 1) {
thrownew Fault(new Exception("无授权信息!"));
}
Elementauth = null;
for(Header header : headers) {
QNameqname = header.getName();
Stringns = qname.getNamespaceURI();
StringtagName = qname.getLocalPart();
if(ns != null && ns.equals("http://zhangshufei/auth")&& tagName != null && tagName.equals("auth")) {
auth= (Element)header.getObject();
break;
}
}
if(auth == null) {
thrownew Fault(new Exception("无授权信息!"));
}
NodeListnameList = auth.getElementsByTagName("name");
NodeListpwdList = auth.getElementsByTagName("password");
if(nameList.getLength() != 1 || pwdList.getLength() != 1) {
thrownew Fault(new Exception("授权信息错误!"));
}
Stringname = nameList.item(0).getTextContent();
Stringpassword = pwdList.item(0).getTextContent();
if(!"admin".equals(name) || !"admin".equals(password)) {
thrownew Fault(new Exception("授权信息错误!"));
}
}
}
十七、 applicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.2.xsd
http://cxf.apache.org/jaxwshttp://cxf.apache.org/schemas/jaxws.xsd" >
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<bean id="hello" class="com.firstws.test.HelloWorldImpl"/>
<jaxws:endpoint id="helloWorld" implementor="#hello" address="/HelloWorld">
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
<bean class="com.firstws.spring.AuthValidateInterceptor"></bean>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>
</jaxws:outInterceptors>
</jaxws:endpoint>
<!--
<bean id="myhw"class="com.firstws.test.HelloWorld"factory-bean="clientFactory" factory-method="create" />
<bean id="clientFactory"class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<propertyname="serviceClass"value="com.firstws.test.HelloWorld"/>
<propertyname="address"value="http://localhost:8080/wbInter/HelloWorld"/>
</bean>
-->
</beans>
十八、 web.xml
<?xml version="1.0"encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CXFService</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
十九、 所引用的jar包
aopalliance-1.0.jar
asm-3.3.1.jar
commons-logging-1.1.3.jar
cxf-core-3.0.7.jar
cxf-manifest.jar
cxf-rt-bindings-soap-3.0.7.jar
cxf-rt-databinding-jaxb-3.0.7.jar
cxf-rt-frontend-jaxws-3.0.7.jar
cxf-rt-frontend-simple-3.0.7.jar
cxf-rt-transports-http-3.0.7.jar
cxf-rt-transports-http-jetty-3.0.7.jar
cxf-rt-ws-addr-3.0.7.jar
cxf-rt-ws-policy-3.0.7.jar
cxf-rt-wsdl-3.0.7.jar
geronimo-jaxws_2.2_spec-1.2.jar
jaxb-api-2.2.11.jar
jaxb-core-2.2.11.jar
jaxb-impl-2.2.11.jar
jetty-continuation-8.1.15.v20140411.jar
jetty-http-8.1.15.v20140411.jar
jetty-io-8.1.15.v20140411.jar
jetty-security-8.1.15.v20140411.jar
jetty-server-8.1.15.v20140411.jar
jetty-util-8.1.15.v20140411.jar
neethi-3.0.3.jar
servlet-api.jar
slf4j-api-1.7.9.jar
slf4j-jdk14-1.7.9.jar
spring-aop-3.2.14.RELEASE.jar
spring-beans-3.2.14.RELEASE.jar
spring-context-3.2.14.RELEASE.jar
spring-core-3.2.14.RELEASE.jar
spring-expression-3.2.14.RELEASE.jar
spring-web-3.2.14.RELEASE.jar
stax2-api-3.1.4.jar
woodstox-core-asl-4.4.1.jar
wsdl4j-1.6.3.jar
xmlschema-core-2.2.1.jar
二十、 客户端程序InterceperSpringTest.java
package com.firstws.spring;
importorg.apache.cxf.interceptor.LoggingInInterceptor;
importorg.apache.cxf.interceptor.LoggingOutInterceptor;
importorg.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import com.firstws.test.HelloWorld;
public class InterceperSpringTest{
publicstatic void main(String[] args) {
JaxWsProxyFactoryBeanfactory = new JaxWsProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:8080/wbInter/HelloWorld");
factory.getInInterceptors().add(newLoggingInInterceptor());
factory.getOutInterceptors().add(newLoggingOutInterceptor());
factory.getOutInterceptors().add(newAuthAddInterceptor());
factory.getOutInterceptors().add(newAuthValidateInterceptor());
HelloWorldhw = (HelloWorld) factory.create();
Stringresult = hw.sayHi("张述飞");
System.out.println("终于出来了=="+result);
}
}
=====================================================================
这里注意先要启动Tomcat服务器,再运行InterceperSpringTest,在服务器端会显示
2016-1-6 14:02:50org.apache.cxf.services.HelloWorldImplService.HelloWorldImplPort.HelloWorld
信息: Inbound Message
----------------------------
ID: 1
Address:http://localhost:8080/wbInter/HelloWorld
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml;charset=UTF-8
Headers: {Accept=[*/*],cache-control=[no-cache], connection=[keep-alive], Content-Length=[307],content-type=[text/xml; charset=UTF-8], host=[localhost:8080],pragma=[no-cache], SOAPAction=[""], user-agent=[Apache CXF 3.0.7]}
Payload: <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><authxmlns="http://zhangshufei/auth"><name>admin</name><password>admin</password></auth></soap:Header><soap:Body><ns2:sayHixmlns:ns2="http://test.firstws.com/"><arg0>张述飞</arg0></ns2:sayHi></soap:Body></soap:Envelope>
--------------------------------------
哈哈开始验证了!
sayHi方法被调用!
2016-1-6 14:02:51org.apache.cxf.services.HelloWorldImplService.HelloWorldImplPort.HelloWorld
信息: Outbound Message
---------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayHiResponsexmlns:ns2="http://test.firstws.com/"><return>Hello 张述飞</return></ns2:sayHiResponse></soap:Body></soap:Envelope>
--------------------------------------
在客户端会显示,在这里不知道为什么会报一个跳过拦截的警告,有知道的,请分享一下,谢谢!!
警告: Skipping interceptorcom.firstws.spring.AuthValidateInterceptor: Phase pre-invoke specified does notexist.
2016-1-6 14:02:50 org.apache.cxf.services.HelloWorldService.HelloWorldPort.HelloWorld
信息: Outbound Message
---------------------------
ID: 1
Address:http://localhost:8080/wbInter/HelloWorld
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], SOAPAction=[""]}
Payload: <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><authxmlns="http://zhangshufei/auth"><name>admin</name><password>admin</password></auth></soap:Header><soap:Body><ns2:sayHixmlns:ns2="http://test.firstws.com/"><arg0>张述飞</arg0></ns2:sayHi></soap:Body></soap:Envelope>
--------------------------------------
2016-1-6 14:02:51org.apache.cxf.services.HelloWorldService.HelloWorldPort.HelloWorld
信息: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type:text/xml;charset=UTF-8
Headers:{content-type=[text/xml;charset=UTF-8], Date=[Wed, 06 Jan 2016 06:02:51 GMT],Server=[Apache-Coyote/1.1], transfer-encoding=[chunked]}
Payload: <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayHiResponsexmlns:ns2="http://test.firstws.com/"><return>Hello 张述飞</return></ns2:sayHiResponse></soap:Body></soap:Envelope>
--------------------------------------
终于出来了==Hello 张述飞
====================================================================
最后注意一个错误
org.apache.cxf.interceptor.Fault:Could not send Message.
atorg.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
~~~~~~~
这个有可能是没有启动Tomcat,或者
factory.setAddress("http://localhost:8080/wbInter/HelloWorld”)的地址写的不对!!
好了,到这里为止,CXF自定义拦截器已经做出来了,另外吐槽一下CSDN的博客发布,能不能直接导入word格式的文件包括里面的图片,每次发布博客时,先在Word中写好,然后复制粘贴,最后再把图片一个个的复制出来,然后才能填加到博客中,很不友好啊!还能不能好好的玩耍了,能不能不让我们这群懒人们少动一下啊,再智能一下好吗???
代码下载地址: http://download.csdn.net/detail/zhangshufei8001/9393027
相关推荐
【CXF3.0.2+Spring3.2.14 WebService入门实例四】的知识点解析 在本文中,我们将深入探讨如何使用Apache CXF 3.0.2版本和Spring 3.2.14框架来创建一个基于WebService的文件传输应用。Apache CXF是一个流行的开源...
简单的webservice+Cxf+Spring数据对接实例以及jar.rar简单的webservice+Cxf+Spring数据对接实例以及jar.rar简单的webservice+Cxf+Spring数据对接实例以及jar.rar简单的webservice+Cxf+Spring数据对接实例以及jar.rar...
以上是CXF+Spring实现Web Service的基本流程和关键知识点。实际应用中,还需要根据具体的需求和环境进行适当的调整和扩展。例如,如果涉及到大型分布式系统,可能还需要考虑服务治理、负载均衡等问题。通过熟练掌握...
在本文中,我们将深入探讨如何使用Apache CXF 2与Spring 2.5框架来开发Web服务实例。Apache CXF是一个流行的开源项目,它提供了一种简单且强大的方式来实现和消费SOAP和RESTful Web服务。Spring框架则以其模块化、...
当我们谈论"CXF3.0.9+SPRING开发webservice例子"时,这意味着我们将探讨如何结合这两个强大的工具来创建和消费Web服务。 首先,让我们深入了解CXF。Apache CXF是基于Java的,它支持多种Web服务标准,如SOAP、...
总的来说,"cxf+spring的webservice实例"是一个实践性的教程,旨在帮助开发者理解如何在Spring环境中利用CXF快速构建和部署Web服务。通过这个实例,你可以掌握从创建服务到发布、测试的整个流程,进一步提升你的Java...
本教程将深入探讨如何利用Apache CXF 2与Spring 2.5来构建和使用WebService。 首先,让我们理解这两个组件的基本概念。Apache CXF是一个全面的服务框架,它支持多种Web服务规范,如SOAP、RESTful、WS-*等。它提供了...
【标签】"CXF+spring WebService CXF"强调了这些组件的集成,特别是CXF作为Web服务的主要提供者,以及与Spring的紧密配合。CXF不仅可以用作服务提供者,还可以作为客户端来消费其他服务,这在Spring的管理下变得更加...
这里少了一个类,是根据实体类生成xml的文件下载地址为:http://download.csdn.net/detail/qq_14996421/9495688
web项目使用spring和cxf的一个开发实例,有简单的代码样例和jar。是一个完整的项目,最终发布完成时访问 http://ip:port/项目名称/webservices/ 就会发现你发布的webservice服务。
描述中提到的"利用CXF3.0.2+Spring3.2.14发布WSSecurity"意味着该压缩包可能包含了一个演示或者教程,展示了如何配置和使用这两个版本的软件来启用Web服务的安全特性。"需要源代码可以下载"则暗示这个压缩包里可能...
【标题】"CXF+Spring+Tomcat发布WebService"涉及的是使用Apache CXF框架与Spring框架结合,在Tomcat服务器上部署和消费Web服务的过程。这是一个常见的企业级应用开发场景,特别是对于实现基于SOAP协议的Web服务。...
Spring + cxf = webservice 完整实例源码免费下载 完全免费。此资源仅为文档提供。 版权为百度文档 "Spring + cxf = webservice 完整实例源码免费下载" 所有。
本实例将详细阐述如何利用CXF和Spring来构建Web服务的客户端和服务端。 一、CXF简介 CXF是一个开源的Java框架,专门用于构建和消费Web服务。它支持SOAP、RESTful等多种服务模型,并且可以方便地与Spring框架集成,...
本项目“cxf+spring发布webservice和restservice”专注于利用Apache CXF框架与Spring框架结合,实现这两种服务的发布。Apache CXF是一个开源的、功能丰富的服务栈,它使得开发者能够轻松地构建和部署SOAP和RESTful ...
Web项目中基于Maven与Spring整合的WebService之cxf的实现⬇️ 详情请参考如下链接: https://locqi.github.io/locqi.com/2018/09/05/Eclipse+Maven+Spring+CXF-create-WebService/
在本教程中,我们将深入探讨如何使用Apache CXF 3.0与Spring 3.2框架构建一个简单的"Hello World" Web服务实例。这个过程涵盖了关键的技术组件、配置步骤以及可能遇到的问题解决策略。 首先,Apache CXF是一个开源...
- **依赖注入(DI)**:Spring的DI允许CXF组件轻松地接收来自Spring容器的依赖,无需硬编码实例化。 - **配置简化**:通过Spring配置文件,可以集中管理Web服务的生命周期和配置。 - **测试友好**:Spring的单元...
标题 "cxf+spring=webservice CXF 应用开发" 暗示了我们将讨论如何结合Apache CXF和Spring框架来创建Web服务。Apache CXF是一个开源的Java框架,主要用于构建和部署SOAP和RESTful Web服务。Spring框架则是一个广泛...
【xfire+Spring+WebService 入门实例详解】 在IT行业中,Web服务是一个重要的通信方式,它允许不同系统间的应用程序进行数据交换。本入门实例将深入探讨如何使用XFire框架与Spring集成来构建和消费Web服务。XFire是...