Bean:
@XmlType(name = "Tower")
@XmlAccessorType(XmlAccessType.FIELD)
public class Tower {
public String name;
public String date;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Tower () {
};
}
接口:
public interface IWsfb
{
public List<Tower> browse() throws Exception;
}
实现类:
@WebService(endpointInterface = "com.ws.IWsfb")
@Features(features = "org.apache.cxf.feature.LoggingFeature") //soap日志输出
public class WsfbMgr implements IWsfb
{
public List<Tower> browse() throws Exception
{
Tower tower = new Tower();
tower.setName('test');
tower.setDate('2009-10-30');
List data = new ArrayList();
data.add(tower);
return data;
}
}
注:bean一定要有个构造方法
分享到:
相关推荐
【标题】:在Java EE环境中,使用Apache CXF与Spring框架整合实现Web服务,返回List、Bean、String、JSON及XML的完整项目实例 【描述】:本项目旨在展示如何在Java企业级应用(Java EE)中,通过Apache CXF框架创建...
public List<Product> getProducts(List<Integer> productIds) { // 实现获取对应产品列表的逻辑 } public Order createOrder(Order order) { // 实现创建订单的业务逻辑 } } ``` 接下来,我们需要在CXF的...
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus"> <property name="outInterceptors"> <list> <!-- 添加自定义拦截器 --> </list> </property> </bean> ``` 2. **CXF服务提供者配置** 接...
<bean id="servletHandler" class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"> <property name="contextAttribute" value="org.apache.catalina.core....
<bean id="helloWorldServiceBeanInfo" class="org.codehaus.xfire.xmlbeans.XmlBeansServiceInfoFactory"> <constructor-arg> <value>com.example.HelloWorldService</value> </constructor-arg> </bean> ...
extends Message>> outInterceptors = new ArrayList<>(); outInterceptors.add(new MyClientOutInterceptor()); factory.setOutInterceptors(outInterceptors); MyService myService = (MyService) factory....
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus"> <property name="configurationClasses"> <list> <value>org.apache.cxf.bus.spring.BusWiringBean</value> </list> </property> </bean> ```...
<bean id="xfireServiceExporter" class="org.springframework.remoting.jaxws.JaxWsServiceExporter"> <property name="serviceInterfaces"> <list> <value>com.example.MyWebService</value> </list> </...
<bean id="cxf" class="org.apache.cxf.frontend.ServerFactoryBean"> ... <property name="serviceBeans"> <list> <ref bean="myWebService"/> </list> </property> ... </bean> <bean id="myWebService...
<bean id="jaxrsServerFactoryBean" class="org.apache.cxf.jaxrs.JAXRSServerFactoryBean"> <property name="serviceBeans"> <list> <ref bean="helloService" /> </list> </property> <property name=...
<bean id="xfireServiceFactory" class="org.codehaus.xfire.spring.XFireServiceFactoryBean"> <property name="serviceClass" value="com.example.YourWebService"/> <property name="serviceBean" ref=...
<bean id="xfire" class="org.codehaus.xfire.spring.XFireFactoryBean"> <property name="serviceList"> <list> <bean class="org.codehaus.xfire.service.ServiceBean"> <property name="serviceClass" value=...
<param-value>WEB-INF/cxf-beans.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <welcome-file-...
</bean> <xfire:service name="UserService" bean="userService"> <xfire:aegisBinding/> </xfire:service> </beans> ``` 4. **部署和测试**:将项目部署到Web服务器(如Tomcat)上,启动服务器,通过浏览器...
- 在此配置文件中,定义了如何创建和管理`SaleService`接口的bean实例。 - **CXF的Spring配置文件**: - 该配置文件主要用于配置CXF相关的组件,如端点(Endpoint)、数据绑定器等。 - **修改web.xml**: - 添加...
private List<User> users = new ArrayList<>(); @Override public void add(User user) { users.add(user); } @Override public User[] findAllUsers() { return users.toArray(new User[users.size()]);...
List<House> getAllHouses(); void rentHouse(House house); } ``` 然后,实现这个接口并添加具体的功能: ```java @Service public class HouseRentServiceImpl implements HouseRentService { @Autowired ...
例如,对于上述的`MyUserService`,客户端可以创建一个`MyUserService`的实例,然后调用`hello`方法,传递参数并接收返回结果。 ```java MyUserService service = new MyUserService_Service()....