cxf实现webservice
来源:互联网 发布:网络信息安全会议记录 编辑:程序博客网 时间:2024/06/07 07:12
1.所需的依赖的包:
commons-logging-1.1.jar
geronimo-activation_1.1_spec-1.0-M1.jar (or Sun's Activation jar)
geronimo-annotation_1.0_spec-1.1.jar (JSR 250)
geronimo-javamail_1.4_spec-1.0-M1.jar (or Sun's JavaMail jar)
geronimo-servlet_2.5_spec-1.1-M1.jar (or Sun's Servlet jar)
geronimo-ws-metadata_2.0_spec-1.1.1.jar (JSR 181)
jaxb-api-2.1.jar
jaxb-impl-2.1.6.jar
jaxws-api-2.1.jar
jetty-6.1.5.jar
jetty-util-6.1.5.jar
neethi-2.0.jar
saaj-api-1.3.jar
saaj-impl-1.3.jar
stax-api-1.0.1.jar
wsdl4j-1.6.1.jar
wstx-asl-3.2.1.jar
XmlSchema-1.2.jar
xml-resolver-1.2.jar
spring jar 包, 用来支持xml配置:
aopalliance-1.0.jar
spring-core-2.0.4.jar
spring-beans-2.0.4.jar
spring-context-2.0.4.jar
spring-web-2.0.4.jar
CXF jar包:
cxf-2.1.jar
以上jar 包 可从apache官方网站下载 apache-cxf-2.1.2.zip, 然后从apache-cxf-2.1.2/lib 目录中获得
2. web.xml中配置:
<!--hyt 20170720 -->
<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>/webservice/*</url-pattern>
</servlet-mapping>
3.使用的applicationContext-shiro-nocas.xml中暴露setvlet
<bean id="chainDefinitionSectionMetaSource" class="ins.policy.**.ChainDefinitionSectionMetaSource">
<property name="filterChainDefinitions">
<value>
<!-- 静态资源区 -->
/devjs/** = anon
/js/** = anon
/dist/** = anon
/css/** = anon
/img/** = anon
/plugins/** = anon
/favicon.ico = anon
/verification/** = anon
/webservice/** = anon
/**/app/** = anon
/logout=logout
/** =user
</value>
</property>
</bean>
在applicationContext-cxf.xml下配置
<jaxws:server id="pacgServiceSoap"
serviceClass="ins.com.application.*.*.service.facade.PacgService"
address="/pacgService">
<jaxws:serviceBean>
<!-- 要暴露的 bean 的引用 -->
<!-- <ref bean="pacgService" /> -->
<bean class="ins.com.application.*.*.service.impl.PacgServiceImpl"></bean>
</jaxws:serviceBean>
<jaxws:inInterceptors>
<ref bean="inMessageInterceptor" />
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref bean="outLoggingInterceptor" />
</jaxws:outInterceptors>
</jaxws:server>
4.新建接口:如下
package ins.com.application.*.*.service.facade;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(targetNamespace="http://localhost:8080/webservice/pacgService")
public interface PacgService {
@WebMethod()
public String newService(@WebParam(name="xml") String xml);
}
实现类如下:
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class PacgServiceImpl implements PacgService {
public String newService( String xml) {
System.out.println("1");
}
}
5.发布成功,查看
http://localhost:8080/webservice
6.客户端调用
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(wsdlmed);
//new javax.xml.namespace.QName
//第一个参数:发布的wsdl里的targetNamespace里的url
//第二个参数:方法名
call.setOperationName(new javax.xml.namespace.QName("http://localhost:8080/webservice/pacgService",
"newService"));
call.setSOAPActionURI(soapuri);
call.setEncodingStyle(null);
/ /addParameter :@WebParam(name="xml") 参数名
call.addParameter("xml",org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN) ;
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setTimeout(300000);
String xml="123";
String result = (String) call.invoke(new Object[] { xml });
- cxf实现soap webservice
- CXF+Spring 实现WebService
- Apache CXF实现WebService
- CXF+Spring 实现WebService
- CXF完整实现WebService
- CXF 实现webservice
- CXF实现webService服务
- CXF+Spring实现webservice
- CXF实现webservice
- cxf实现webservice服务端
- CXF+Spring 实现webService
- cxf+spring 实现webservice
- webService实现之cxf
- cxf+spring实现webservice
- CXF框架实现WebService
- cxf实现webservice
- Webservice实例-使用CXF实现
- CXF实现WebService动态调用。
- CSDN-markdown编辑器使用指南
- python 文件操作
- checkbox
- 2017年第二十五届中国(深圳)国际礼品及家居用品展览会会刊(参展商名录)
- spring boot 配置Cache
- cxf实现webservice
- MongoDB干货系列2-MongoDB执行计划分析详解(2)
- Errors occurred during the build. Errors running builder 'Integrated External Tool Builder' on proje
- JS回调函数--简单易懂有实例
- js中append函数引用函数的时候传参方法
- 推荐 | 10.24......送你9大深度学习在线课程,你没理由不看!(附链接......)
- hive mapjoin 使用
- Java中System.setProperty()用法
- tomcat的8080端口被占用的解决方法