<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 引入XFire预配置信息 -->
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
<!-- 定义访问的url -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/HelloWorldService"> <!-- key="/HelloWorldService.ws" -->
<ref bean="HelloWorldService" />
</entry>
</map>
</property>
</bean>
<!-- 使用XFire导出器 -->
<bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" lazy-init="false" abstract="true">
<!-- 引用xfire.xml中定义的工厂 -->
<property name="serviceFactory" ref="xfire.serviceFactory" />
<!-- 引用xfire.xml中的xfire实例 -->
<property name="xfire" ref="xfire" />
</bean>
<bean id="HelloWorldService" parent="baseWebService">
<!-- 业务服务bean -->
<property name="serviceBean" ref="HelloWorldBean" />
<!-- 业务服务bean的窄接口类 -->
<property name="serviceClass" value="webservice.HelloWorld" />
</bean>
</beans>
<5>接口webservice:
package webservice;
public interface HelloWorld {
String sayHelloWorld(String name,String codeId);
}
<6>实现类HelloWorldImpl :
package webservice;
public class HelloWorldImpl implements HelloWorld {
public String sayHelloWorld(String name,String codeId) {
String helloWorld = "hello," + name+",codeId="+ codeId;
return helloWorld;
}
}
<7>测试类:
package test;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import webservice.HelloWorld;
public class Client {
public static void main(String[] args) {
try {
Service model = new ObjectServiceFactory().create(HelloWorld.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String url = "http://localhost:8080/webservice_helloworld/HelloWorldService.ws";
HelloWorld hs = (HelloWorld) factory.create(model, url);
System.out.println(hs.sayHelloWorld("李赞红","951753"));
//Course course = hs.choose(new User("李世民", 1));
//System.out.println(course.getName());
List list1 = new ArrayList();
list1.add("111");
list1.add("222");
list1.add("333");
//List list = hs.test(list1);
for(Object o : list1){
//Course c = (Course) o;
//System.out.println(c.getName());
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
分享到:
相关推荐
<xfire:service id="calculator" bean="#calculatorService"> <xfire:binding> <xfire:jaxws/> </xfire:binding> <xfire:endpoint address="/calculator"/> </xfire:bean> ``` 5. **启动Web服务**: 配置完成...
<groupId>org.codehaus.xfire</groupId> <artifactId>xfire-aegis</artifactId> <version>1.2.6</version> </dependency> <dependency> <groupId>org.codehaus.xfire</groupId> <artifactId>xfire-core</...
<groupId>org.codehaus.xfire</groupId> <artifactId>xfire-all</artifactId> <version>1.2.6</version> </dependency> </dependencies> ``` 3. **定义服务接口和服务实现**:创建一个Java接口,声明要公开的...
<param-value>classpath*:spring/*.xml,classpath:org/codehaus/xfire/spring/xfire.xml</param-value> </context-param> ``` 此外,还需要添加一些特定于**xFire**的配置: ```xml <!--xFirebegin--> <context-...
<servlet-name>AxisServlet</servlet-name> <servlet-class> org.apache.axis.transport.http.AxisServlet </servlet-class> </servlet> <servlet> <servlet-name>AdminServlet</servlet-name> ...
<groupId>org.codehaus.xfire</groupId> <artifactId>xfire-all</artifactId> <version>1.2.6</version> </dependency> ``` ```xml <xfire> <services> <service name="CalculatorService" serviceClass=...
<artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.x.x</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.x.x....
<servlet-name>xfire</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>xfire</servlet-name> <url-pattern>*....
<groupId>org.codehaus.xfire</groupId> <artifactId>xfire-all</artifactId> <version>1.2.6</version> </dependency> <!-- 其他相关依赖 --> </dependencies> ``` **创建 Web 服务** 在 XFire 中,Web 服务...
<param-value>classpath:org/codehaus/xfire/spring/xfire.xml, classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context....
综上所述,"webservice Soap和XFire2种方式代码列子"的压缩包可能包含使用SOAP协议和XFire框架创建Web服务的示例代码。通过学习这些代码,开发者可以更好地理解如何在Java环境中构建和消费SOAP服务,以及XFire在其中...
<dwType>被定位手机号码的类型</dwType> </info> ``` 3. **返回的XML信息格式**: 服务响应包括定位的电话号码、结果状态码、纬度、经度、高度、半径、模式以及文本描述位置信息。例如: ``` <?xml version="1.0...
<servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>XFireServlet</servlet-name> <url-pattern>/services/*</url-...
List<UserInfo> list = (ArrayList<UserInfo>) iAddressService .getAddressList(); System.out.println("一共多少条数据:" + list.size()); for (Iterator<UserInfo> iter = list.iterator(); iter.hasNext...
里面包括了3个PDF文档<br>1:Xfire-野猪书-开发指南<br>2:xfiretutorial<br>3:xfire-spring<br>为你的工程提供一个更好的远程服务,做好数据交换第一步<br>XFire是当前J2EE领域非常流行的Web Service框架,以其卓越的...
<param-name>xfire.config</param-name> <param-value>/WEB-INF/xfire-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>xfire</...
<bean id="xfireServiceExporter" class="org.springframework.remoting.jaxws.JaxWsServiceExporter"> <property name="serviceInterfaces"> <list> <value>com.example.MyWebService</value> </list> </...
<xfire:xfire> <xfire:service id="helloWorldService" bean="#helloWorldServiceImpl"> <xfire:interface>com.example.HelloWorldService</xfire:interface> <xfire:binding> <xfire:soapBinding version="1.1...