cxf
一,cxf webService入门案例
1,jar包
注意版本 使用jdk6和apache-cxf-3.1.2,但cxf-3.1.2已经不支持jdk6,需要jdk7以上
版本用错会报java.lang.UnsupportedClassVersionError: org/apache/cxf/transport/servlet/CXFServlet : Unsupported major.minor version 51.0
下载地址: 取lib下的jar
http://www.apache.org/dyn/closer.lua/cxf/2.7.18/apache-cxf-2.7.18.zip
2,新建web工程
3,java代码
package com.lxl.it.cxf.service; import javax.jws.WebService; @WebService
public interface ITestCxfWs {
String sayHi(String text);
}
ITestCxfWs接口
package com.lxl.it.cxf.service.impl; import javax.jws.WebService; import com.lxl.it.cxf.service.ITestCxfWs;
@WebService(endpointInterface="com.lxl.it.cxf.service.ITestCxfWs",serviceName="testCxfWs")
public class TestCxfWs implements ITestCxfWs{ @Override
public String sayHi(String text) {
return text;
} }
TestCxfWs实现类
package com.lxl.it.cxf.service.test; import javax.xml.ws.Endpoint; import com.lxl.it.cxf.service.impl.TestCxfWs; public class WebServiceApp {
public static void main(String[] args) {
System.out.println("WebServiceApp satrt");
TestCxfWs ws=new TestCxfWs();
String address="http://localhost:8080/testCxfWs";
Endpoint.publish(address, ws);
System.out.println("WebServiceApp end");
}
}
代码发webService
4,xml配置 web.xml spring配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>TestWebService</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
</web-app>
web.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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <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" /> <jaxws:endpoint id="testCxfWs" implementor="com.lxl.it.cxf.service.impl.TestCxfWs"
address="/testCxfWs" /> <bean id="client" class="com.lxl.it.cxf.service.ITestCxfWs" factory-bean="clientFactory"
factory-method="create" /> <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.lxl.it.cxf.service.ITestCxfWs" />
<property name="address" value="http://localhost:8080/TestWebService/webservice/testCxfWs" />
</bean>
</beans>
spring
二,cxf增加拦截器
1,工程
2,java代码
package com.lxl.it.cxf.service.Interceptor; import java.lang.reflect.Method;
import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.cxf.frontend.MethodDispatcher;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.transport.http.AbstractHTTPDestination; import com.lxl.it.utils.IpUtil;
import com.lxl.it.utils.StringUtils;
import com.lxl.it.utils.Tuple2;
/**
* 对webservice的请求ip地址进行限制的拦截器
*
*/
public class IpAddressInInterceptor extends AbstractPhaseInterceptor<Message>{ public IpAddressInInterceptor() {
super(Phase.USER_LOGICAL);
}
@Override
public void handleMessage(Message msg) throws Fault { String ip = "0.0.0.0";
HttpServletRequest httpRequest = (HttpServletRequest) msg
.get(AbstractHTTPDestination.HTTP_REQUEST); if (null != httpRequest) {
ip = StringUtils.getIpFromRequest(httpRequest);
}else{
return;
} Exchange exchange = msg.getExchange();
Method paramMethod = ((MethodDispatcher) exchange.get(Service.class)
.get(MethodDispatcher.class.getName())).getMethod(exchange
.get(BindingOperationInfo.class));
String method = paramMethod.toString();
List<Tuple2<Long, Long>> ips =null;//这里是获取系统配置的ip白名单
//ips=InterfaceMethodCache
// .getAuthorizedIp(method);
// if (ips == null || ips.isEmpty()) {
// // 然后用类名称查找配置
// method = paramMethod.getDeclaringClass().getName();
// ips = InterfaceMethodCache.getAuthorizedIp(method);
// }
if (ips == null || ips.isEmpty()) {
return;
} if (!IpUtil.ipCheck(ip, ips)) {
throw new Fault(new IllegalAccessException("method id[" + method
+ "] & ip address[" + ip + "] is denied!"));
} } }
IpAddressInInterceptor
package com.lxl.it.utils; import java.util.List; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; public class IpUtil { private static final Logger logger = LoggerFactory.getLogger(IpUtil.class); /**
* 将IP转成整数
*
* @param ip
* @return
*/
public static long ipToLong(String ip) {
long res = 0;
String[] ss = ip.split("\\.");
res = ((Long.valueOf(ss[0]) * 256 + Long.valueOf(ss[1])) * 256 + Long
.valueOf(ss[2])) * 256 + Long.valueOf(ss[3]);
return res;
} /**
* 校验IP是否合法
*
* @param ip
* @param ips
* @return
*/
public static boolean ipCheck(String ip, List<Tuple2<Long, Long>> ips) {
return ipCheck(ipToLong(ip), ips);
} public static boolean ipCheck(long ip, List<Tuple2<Long, Long>> ips) {
for (Tuple2<Long, Long> tuple : ips) {
if ((ip >= tuple._1 && ip <= tuple._2) || ip == 0L)
return true;
}
return false;
} public static boolean ipCheck(String ip, Tuple2<Long, Long> tuple) {
return ipCheck(ipToLong(ip), tuple);
} public static boolean ipCheck(long ip, Tuple2<Long, Long> tuple) {
return (ip >= tuple._1 && ip <= tuple._2);
} private static String getCheckword(String xml) {
String checkword = null;
try {
if (xml != null) {
int sIndex = xml.indexOf("<checkword>");
int eIndex = xml.indexOf("</checkword>"); if (sIndex != -1 && eIndex != -1) {
checkword = xml.substring(sIndex + "<checkword>".length(),
eIndex);
}
}
} catch (Exception e) {
// e.printStackTrace();
logger.error("", e);
}
return checkword;
} public static void main(String[] args) {
// System.out.println(ipToLong("0.0.0.0"));
// System.out.println(ipToLong("255.255.255.255"));
}
}
IpUtil
package com.lxl.it.utils; /**
* Copyright (c) 2013, S.F. Express Inc. All rights reserved.
*/ import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; public class StringUtils { private static Logger logger = LoggerFactory.getLogger(StringUtils.class); /*
* 16进制数字字符集
*/
private static String hexString = "0123456789ABCDEF"; public static boolean isNotEmpty(String str) {
return !isEmpty(str);
} public static boolean isEmpty(String str) {
return str == null || str.trim().length() == 0;
} public static String toString(Object o) {
if (o == null)
return null;
return o.toString();
} // private static final String BR = "<br>\n"; public static String throwableToString(Throwable e) {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
e.printStackTrace(new PrintWriter(buf, true));
return buf.toString();
// StringBuilder sb = new StringBuilder();
// try {
// throwableToString(e, sb);
// } catch (Exception e1) {
// sb.append("parse and print exception error.");
// }
// return sb.toString();
} // @SuppressWarnings("unchecked")
// private static void throwableToString(Throwable e, StringBuilder sb) {
// if (e == null)
// sb.append("#Exception:NULL");
// else {
// sb.append(BR).append(e.getClass().getName()).append(":").append(e.getMessage()).append(BR)
// .append("#StackTrace:");
// boolean isIterable = false;
// if (e instanceof Iterable) {
// try {
// StringBuilder sb2 = new StringBuilder();
// for (Throwable t : (Iterable<Throwable>) e)
// throwableToString(t, sb2);
// sb.append(sb2);
// isIterable = true;
// } catch (Exception e1) {
// isIterable = false;
// }
// }
// if (!isIterable) {
// for (StackTraceElement ele : e.getStackTrace())
// sb.append(BR).append(ele.toString());
// }
// }
// } /**
* 从request中获取ip地址
*
* @param request
* 请求
* @return
*/
public static String getIpFromRequest(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
if (ip != null) {
int idx = ip.indexOf(',');
if (idx > 0) {
ip = ip.substring(0, idx);
}
}
return ip;
} /**
* null和空字符串认为空
*
* @param target
* @return
*/
public static boolean isBlank(String target) {
return isEmpty(target);
} /**
* 按字节数截取字符串
*
* @param orignal
* 字符串
* @param count
* 需要截取的字节数
* @return
* @throws UnsupportedEncodingException
*/
public static String substring(String orignal, int count)
throws UnsupportedEncodingException {
// 原始字符不为null,也不是空字符串
if (!isEmpty(orignal)) {
// 将原始字符串转换为UTF-8编码格式
orignal = new String(orignal.getBytes(), "UTF-8");
// 要截取的字节数大于0,且小于原始字符串的字节数
if (count > 0 && count < orignal.getBytes("UTF-8").length) {
StringBuffer buff = new StringBuffer();
boolean lastCharIsChineses = false; char c;
for (int i = 0; i < count; i++) {
c = orignal.charAt(i);
buff.append(c);
if (isChineseChar(c)) {
lastCharIsChineses = true;
// 遇到中文汉字,截取字节总数减2
--count;
--count;
} else {
lastCharIsChineses = false;
}
} if (lastCharIsChineses) {
buff.deleteCharAt(buff.length() - 1);
} return buff.toString();
}
}
return orignal;
} public static boolean isChineseChar(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION) {
return true;
}
return false;
} private static final int[] BYTES_COUNT = new int[] { 0x80, 0x40, 0x20,
0x10, 8, 4 }; private static final Charset utf8Charset = Charset.forName("utf-8"); public static String oracleUtf8Sub(String str, int len)
throws UnsupportedEncodingException {
return oracleUtf8Sub(str, 0, len);
} public static String oracleUtf8Sub(String str, int from, int len)
throws UnsupportedEncodingException {
if (str == null || len < 0 || from < 0 || from >= str.length())
throw new IllegalArgumentException(); if (from != 0)
str = str.substring(from); byte[] bs = str.getBytes(utf8Charset); if (len >= bs.length)
return str; int to = 0;
int to_ = 0; while (to <= len) {
to_ = to;
byte b = bs[to];
if (0 <= b && b < 128) {
to += 1;
} else {
for (int i = 1; i <= 5; ++i) {
if ((b & BYTES_COUNT[i]) > 0)
continue;
if (i == 1)
throw new RuntimeException("Error utf8 decode for:"
+ str);
to += i;
break;
}
}
} return new String(bs, 0, to_, utf8Charset);
} /**
* 从含路由的文件名中提取单纯的文件名称
*
* @param pathFileName
* 含路径的文件名称
* @return String
*/
public static String getFileNameFromPath(String pathFileName) {
String fileNameTemp = null;
int lastSplitPos = 0; if (pathFileName.indexOf("/") > -1) {
lastSplitPos = pathFileName.lastIndexOf("/");
fileNameTemp = pathFileName.substring(lastSplitPos + 1,
pathFileName.length());
} else if (pathFileName.indexOf("\\") > -1) {
lastSplitPos = pathFileName.lastIndexOf("\\");
fileNameTemp = pathFileName.substring(lastSplitPos + 1,
pathFileName.length());
} else if (pathFileName.indexOf(":") > -1) {
lastSplitPos = pathFileName.lastIndexOf(":");
fileNameTemp = pathFileName.substring(lastSplitPos + 1,
pathFileName.length());
} else {
fileNameTemp = pathFileName;
} return fileNameTemp;
} public static String getFirstNodeTxt(String xmlStr, String nodeName) {
String resultStr = null; if (StringUtils.isNotEmpty(xmlStr) && StringUtils.isNotEmpty(nodeName)) {
int startIndex = xmlStr.indexOf("<" + nodeName + ">");
int endIndex = xmlStr.indexOf("</" + nodeName + ">"); if (startIndex != -1 && endIndex != -1) {
resultStr = xmlStr.substring(
startIndex + nodeName.length() + 2, endIndex);
} } return resultStr;
} public static String getHexTOString(String bytes) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(
bytes.length() / 2);
// 将每2位16进制整数组装成一个字节
for (int i = 0; i < bytes.length(); i += 2)
baos.write((hexString.indexOf(bytes.charAt(i)) << 4 | hexString
.indexOf(bytes.charAt(i + 1))));
return new String(baos.toByteArray());
} public static String toString(StackTraceElement[] stesElements) {
if (stesElements != null) {
try {
StringBuilder sBuilder = new StringBuilder();
for (StackTraceElement ste : stesElements) {
sBuilder.append(' ').append(ste.toString()).append('\n');
}
return sBuilder.toString();
} catch (Exception e) {
logger.error("", e);
}
}
return null;
} /**
* HTML转义
*
* @param content
* @return
*/
public static String htmlEncode(String content) {
if (content == null)
return ""; String html = content; html = html.replaceAll("&", "&");
html = html.replace("'", "'");
html = html.replace("\"", """); // "
html = html.replace("\t", " ");// 替换跳格
html = html.replace(" ", " ");// 替换空格
html = html.replace("<", "<");
html = html.replaceAll(">", ">"); return html;
} /**
* 输出某个对象的全部属性值
*
* @param obj
* 对象
* @param fieldShow属性名称与属性值之间的分隔符
* @param fieldEndChr属性结束符
* :各个属性之间的分隔符
* @return
*/
public static String outAllFields4Object(Object obj, String fieldShow,
String fieldEndChr) {
if (null == obj) {
return null;
} else {
StringBuilder sbuilder = new StringBuilder(); if (isEmpty(fieldShow)) {
fieldShow = "->";
} if (isEmpty(fieldEndChr)) {
fieldEndChr = ";";
} try {
Class<?> c = obj.getClass();
Field[] fields = c.getDeclaredFields(); sbuilder.append(obj.getClass()).append(":"); for (Field f : fields) {
f.setAccessible(true);
String field = f.toString().substring(
f.toString().lastIndexOf(".") + 1); // 取出属性名称
sbuilder.append(field).append(fieldShow)
.append(f.get(obj) == null ? "" : f.get(obj))
.append(fieldEndChr);
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} return sbuilder.toString();
} }
/**
* 输出某个对象的全部属性值
*
* @param obj
* 对象
* @param fieldShow属性名称与属性值之间的分隔符
* @param fieldEndChr属性结束符
* :各个属性之间的分隔符
* @return
*/
public static String outAllFields4ObjectAndSuper(Object obj, String fieldShow,
String fieldEndChr) {
if (null == obj) {
return null;
} else {
StringBuilder sbuilder = new StringBuilder(); if (isEmpty(fieldShow)) {
fieldShow = "->";
} if (isEmpty(fieldEndChr)) {
fieldEndChr = ";";
} try {
Class<?> c = obj.getClass();
List<Field> fields=new ArrayList<Field>();
fields=getClassField(c,fields); sbuilder.append(obj.getClass()).append(":"); for (Field f : fields) {
f.setAccessible(true);
String field = f.toString().substring(
f.toString().lastIndexOf(".") + 1); // 取出属性名称
sbuilder.append(field).append(fieldShow)
.append(f.get(obj) == null ? "" : f.get(obj))
.append(fieldEndChr);
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} return sbuilder.toString();
} } /**
* 获取类的所有属性,包括父类的
*
* @param aClazz
* @param fieldList
* @return
*/
private static List<Field> getClassField(Class aClazz, List<Field> fieldList) {
Field[] declaredFields = aClazz.getDeclaredFields();
for (Field field : declaredFields) {
fieldList.add(field);
} Class superclass = aClazz.getSuperclass();
if (superclass != null) {// 简单的递归一下
return getClassField(superclass, fieldList);
}
return fieldList;
} /**
* 将非打印字符替换为空格
*
* @param str
* 需处理的字符串
* @param charset
* :字符串编码格式:UTF-8,GBK
* @return
* @throws UnsupportedEncodingException
*/
public static String emptyNotPrintChar(String str, String charset)
throws UnsupportedEncodingException { if (StringUtils.isEmpty(str)) {
return "";
} return new String(emptyNotPrintChar(str.getBytes(charset)), charset);
} /**
* 将非打印字符替换为空格
*
* @param str
* 需处理的字符串
* @return
* @throws UnsupportedEncodingException
*/
public static String emptyNotPrintChar(String str) { if (StringUtils.isEmpty(str)) {
return "";
} return new String(emptyNotPrintChar(str.getBytes()));
} /**
* 将非打印字符替换为空格
*
* @param bts
* 需处理的字节数组
* @return
*/
private static byte[] emptyNotPrintChar(byte[] bts) {
int btsLength = bts.length;
byte[] newBytes = new byte[btsLength];
for (int i = 0; i < btsLength; i++) { byte b = bts[i];
if ((b >= 0 && b <= 31) || b == 127) {
b = 32;
} newBytes[i] = b;
} return newBytes;
} // public static void main(String[] args) throws UnsupportedEncodingException {
// String str = "qwertyuiop中华人民共和国123456789";
// String destStr = "";
//
// destStr = StringUtils.emptyNotPrintChar(str, "UTF-8");
// System.out.println(destStr);
//
// str = "上海杨浦区昆明路739号文通大厦15层 中青旅联科";
// destStr = "";
//
// destStr = StringUtils.emptyNotPrintChar(str, "GBK");
// System.out.println(destStr);
// }
}
StringUtils
package com.lxl.it.utils; import java.io.Serializable; public class Tuple2<T1, T2> implements Serializable { private static final long serialVersionUID = -39962326066034337L; public T1 _1;
public T2 _2; public Tuple2() {
} public Tuple2(T1 _1, T2 _2) {
super();
this._1 = _1;
this._2 = _2;
} /**
* 根据提供的参数,构造Tuple对象
*
* @param _1
* @param _2
* @return
*/
public static <E1, E2> Tuple2<E1, E2> apply(E1 _1, E2 _2) {
Tuple2<E1, E2> res = new Tuple2<E1, E2>();
res._1 = _1;
res._2 = _2;
return res;
} @Override
public String toString() {
return "[" + _1 + ", " + _2 + "]";
} @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((_1 == null) ? 0 : _1.hashCode());
result = prime * result + ((_2 == null) ? 0 : _2.hashCode());
return result;
} @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Tuple2<?, ?> other = (Tuple2<?, ?>) obj;
if (_1 == null) {
if (other._1 != null)
return false;
} else if (!_1.equals(other._1))
return false;
if (_2 == null) {
if (other._2 != null)
return false;
} else if (!_2.equals(other._2))
return false;
return true;
} }
Tuple2
3,配置spring文件
<?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: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/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"> <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" />
<bean id="ipAddressInInterceptor"
class="com.lxl.it.cxf.service.Interceptor.IpAddressInInterceptor" />
<!-- 监听 -->
<cxf:bus>
<cxf:inInterceptors>
<ref bean="ipAddressInInterceptor" />
</cxf:inInterceptors>
</cxf:bus>
<jaxws:endpoint id="testCxfWs"
implementor="com.lxl.it.cxf.service.impl.TestCxfWs" address="/testCxfWs" /> <bean id="client" class="com.lxl.it.cxf.service.ITestCxfWs"
factory-bean="clientFactory" factory-method="create" /> <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.lxl.it.cxf.service.ITestCxfWs" />
<property name="address" value="http://localhost:8080/TestWebService/webservice/testCxfWs" />
</bean> </beans>
spring
注意:
<!-- 监听 -->
<cxf:bus>
<cxf:inInterceptors>
<ref bean="ipAddressInInterceptor" />
</cxf:inInterceptors>
</cxf:bus>
上述监听配置用的cxf标签,需要再spring配置文件头部加上声明
<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: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/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
cxf的更多相关文章
- java调用CXF WebService接口的两种方式
通过http://localhost:7002/card/services/HelloWorld?wsdl访问到xml如下,说明接口写对了. 2.静态调用 // 创建WebService客户端代理工厂 ...
- webService学习之路(三):springMVC集成CXF后调用已知的wsdl接口
webService学习之路一:讲解了通过传统方式怎么发布及调用webservice webService学习之路二:讲解了SpringMVC和CXF的集成及快速发布webservice 本篇文章将讲 ...
- webService学习之路(二):springMVC集成CXF快速发布webService
继上一篇webService入门之后,http://www.cnblogs.com/xiaochangwei/p/4969448.html ,现在我将我周六在家研究的结果公布出来 本次集成是基于之前已 ...
- CXF:根据werservice代码生成WSDL(转)
原文:http://hongyegu.iteye.com/blog/619147,谢谢! import org.apache.cxf.tools.java2ws.JavaToWS; import ne ...
- webservice入门实例,CXF方式
1.下载CXF,及先关jar包. CXF 下载地址:http://cxf.apache.org/download.html,选择"File"列中的zip格式下载.解压后可以看到一些 ...
- 脱离spring集成cxf(基于nutz框架)
什么是webService WebService是一种跨编程语言和跨操作系统平台的远程调用技术. 理论资料: http://blog.csdn.net/wooshn/article/details/8 ...
- WebService -- Java 实现之 CXF ( 使用Spring添加拦截器)
最重要的就是在ApplicationContext.xml下面添加配置 <!-- service provider --> <jaxws:endpoint implementor=& ...
- WebService -- Java 实现之 CXF ( 使用:Spring+CXF+Tomcat发布webService)
1. 新建一个Maven项目,选择webapp模板,命名为WS_Spring_CXF_Tomcat 2. 在POM.xml中添加Spring和CXF的依赖 <!-- 添加 Spring depe ...
- WebService -- Java 实现之 CXF ( 添加系统预定义的拦截器)
1. 概述 CXF允许我们在webservice的in/out位置添加拦截器.拦截器有两大分类,一类是系统预定义的:另一类是自定义拦截器. 2. 在server端添加拦截器. JaxWsServerF ...
- cxf webservice 生成wsdl方法参数名称为arg0问题
在通过cxf生成webservice服务时,如果你是用ServerFactoryBean,那么在生成wsdl时,方法的参数名称会被自动命名为arg0,arg1...,如: <xsd:comple ...
随机推荐
- 【暑假】[深入动态规划]UVa 1628 Pizza Delivery
UVa 1628 Pizza Delivery 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51189 思路: ...
- 【暑假】[深入动态规划]UVa 10618 Fun Game
UVa 10618 Fun Game 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=36035 思路: 一圈人围坐 ...
- 各种排序算法代码(C语言版)
选择排序 #include <stdio.h> /* * 选择排序 * 稳定性:不稳定 * 时间复杂度:O(N^2) **/ void select_sort(int a[], int l ...
- 关于 Java Collections API 您不知道的 5 件事,第 1 部分
定制和扩展 Java Collections Java™ Collections API 远不止是数组的替代品,虽然一开始这样用也不错.Ted Neward 提供了关于用 Collections 做更 ...
- TextView & EditText
TextView 1.下划线 textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线 2.单独做第一步,文字会出现锯齿,要加下 ...
- 用MyGeneration模板生成NHibernate映射文件和关系
用我的MyGeneration模板生成NHibernate映射文件和关系(one-to-one,one-to-many,many-to-many) MyGeneration的几个NHibernate模 ...
- SMP和MAPP的区别
SMP(Symmetrical Multi-Processing),对称多处理系统,是指在一个计算机上汇集了一组处理器(多CPU),各CPU之间共享内存子系统以及总线结构.它是相对非对称多处理技术而言 ...
- CocoaPods容易出现的问题;
一.初次安装cocoapods打开项目遇:Pods-resources.sh: Permission denied报错. 此类报错是指编译器在打开Pods-resources.sh文件的时候遭遇权限问 ...
- MySQL中UNION和UNION ALL的使用
在数据库中,UNION和UNION ALL关键字都是将两个结果集合并为一个,但这两者从使用和效率上来说都有所不同. MySQL中的UNION UNION在进行表链接后会筛选掉重复的记录,所以在表链接后 ...
- hdu3589 Jacobi symbol(二次剩余 数论题)
本题的注意点:n=p1*p2*p3......Pm 解法:直接利用公式a^((p-1)/2)=(a/p)mod p 即可求解. #include<stdio.h> #include< ...