标签:c++ static localhost rgs -name 实现 tab 接口 ups
参考:http://www.cnblogs.com/doosmile/archive/2012/06/21/2557351.html
webservice技术现在已经非常成熟,大浪淘沙后,目前java开发webservice的框架主要包括axis2和cxf。
axis2和cxf都是apache旗下的产品,但是其目的不同,导致webservice开发方法也不一样。两个框架都得到了开发者的支持。有必要对二者进行以下对比。
Axis2 | CXF | |
---|---|---|
目标 | WebService引擎 | 简易的SOA框架,可以作为ESB |
ws* 标准支持 | 不支持WS-Policy | WS-Addressing,WS-Policy, WS-RM, WS-Security,WS-I Basic Profile |
数据绑定支持 | XMLBeans、JiBX、JaxMe 、JaxBRI、ADB | JAXB, Aegis, XMLBeans, SDO, JiBX |
spring集成 | 不支持 | 支持 |
应用集成 | 困难 | 简单 |
多语言 | 支持C/C++ | 不支持 |
部署 | web应用 | 嵌入式 |
服务监控和管理 | 支持 | 不支持 |
结论:
<!-- 服务端---->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.10</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.10</version>
</dependency>
<!-- 客户端 -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.1.10</version>
</dependency>
<!-- 设置Spring容器加载配置文件路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-server.xml</param-value>
</context-param>
<!-- 加载Spring容器配置 -->
<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>/webservice/*</url-pattern>
</servlet-mapping>
</web-app>
xml中添加头文件
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
具体实现:
<bean id="greetingServiceImpl" class="com.mycompany.webservice.server.GreetingServiceImpl"/>
<jaxws:endpoint id="greetingService" implementor="#greetingServiceImpl" address="/Greeting" />
package com.mycompany.webservice.server;
import javax.jws.WebService;
@WebService
public interface Greeting {
public String greeting(String userName);
}
package com.mycompany.webservice.server;
import java.util.Calendar;
import javax.jws.WebService;
@WebService(endpointInterface = "com.mycompany.webservice.server.Greeting")
public class GreetingServiceImpl implements Greeting {
public String greeting(String userName) {
return "Hello " + userName + ", currentTime is "
+ Calendar.getInstance().getTime();
}
}
public class GreetingServiceClient {
public static void main(String[] args) {
//创建WebService客户端代理工厂
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
//注册WebService接口
factory.setServiceClass(Greeting.class);
//设置WebService地址
factory.setAddress("http://localhost:8080/yourProgramName/webservice/Greeting");
Greeting greetingService = (Greeting)factory.create();
System.out.println("invoke webservice...");
System.out.println("message context is:"+greetingService.greeting("gary"));
}
}
标签:c++ static localhost rgs -name 实现 tab 接口 ups
原文地址:http://www.cnblogs.com/brightly/p/6748907.html