环境信息:cxf2.7 spring3.1 tomcat6.0
一、创建webservice接口
web.xml
<?xml version="1.0" encoding="utf-8"?>
<web-app version="3.0"
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_3_0.xsd">
<display-name></display-name>
<!– spring需要加载的配置文件 –>
<context-param>
<param-name>contextconfiglocation</param-name>
<param-value>
classpath:com/server/spring-cxf.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.contextloaderlistener
</listener-class>
</listener>
<!– cxf服务启动servlet –>
<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>/service/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
spring-cxf.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:tx="http://www.springframework.org/schema/tx"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:wsa="http://cxf.apache.org/ws/addressing"
xsi:schemalocation="
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.1.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
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" />
<!– <cxf:bus>
<cxf:features>
日志拦截功能,用于监控soap内容,开发后可以删除
<cxf:logging/>
<wsa:addressing/>
</cxf:features>
</cxf:bus> –>
<bean id="hello" class="com.server.helloworldimpl" />
<jaxws:endpoint id="helloworld" implementor="#hello" address="/helloworld" publish="true"/>
</beans>
helloworld.java
package com.server;
import javax.jws.webservice;
/
* web service 接口声明
*/
@webservice(targetnamespace = "server.com")
public interface helloworld {
/
* sayhi
* @param text
* @return
*/
string sayhi(string text);
}
helloworldimpl.java
package com.server;
import javax.jws.webservice;
/
* web service接口实现
*
*/
@webservice(endpointinterface = "com.server.helloworld")
public class helloworldimpl implements helloworld {
@override
public string sayhi(string text) {
// todo auto-generated method stub
return "hello, " text;
}
}
部署代码后可在浏览器打开http://locahost:8080/项目名称/service/helloworld?wsdl
此时webservice接口开发完成!
二、添加ssl双向认证
利用jdk自带keytool工具:直接cmd后执行:
keytool -genkey -alias test -keyalg rsa -keystore test.keystore -validity 3650
名字和姓氏要填域名或者ip名:服务器端ip。其他可以随便填
这步操作以后,得到test.keystore
keytool -export -alias test -file test.cer -keystore test.keystore
得到一个test.cer,然后把t
华为云服务器怎么恢复备份想咨询一下想变更地址如何操作建网站需要多长时间云服务器同时可以挂几个帐号搜狗输入法怎么设置 搜狗输入法设置的方法特价云服务器购买费用电脑IE浏览器安全级别如何设置【图文】腾讯云服务器怎么加虚拟内存