锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
import J2EE鎶鏈殑鐖櫕.util.Collection;
import J2EE鎶鏈殑鐖櫕.util.List;
public interface IMathService {
/**
* 鍔?br />
* @param a
* @param b
* @return
*/
public int add(int a,int b);
/**
* 鍑?br />
* @param a
* @param b
* @return
*/
public int sub(int a,int b);
/**
涓婁紶浜岃繘鍒舵枃浠?br />
*/
public String sendFile(String fileName,byte[] file );
}
瀹炵幇 implements
import J2EE鎶鏈殑鐖櫕.io.File;
import J2EE鎶鏈殑鐖櫕.io.FileOutputStream;
import J2EE鎶鏈殑鐖櫕.sql.Connection;
import J2EE鎶鏈殑鐖櫕.sql.ResultSet;
import J2EE鎶鏈殑鐖櫕.sql.Statement;
import J2EE鎶鏈殑鐖櫕.util.ArrayList;
import J2EE鎶鏈殑鐖櫕.util.Collection;
import J2EE鎶鏈殑鐖櫕.util.List;
import com.newsoft.oa.bean.User;
import com.newsoft.oa.uitl.Connector;
import com.thoughtworks.xstream.XStream;
public class MathServiceImpl implements IMathService{
public int add(int a,int b){
return a+b;
}
public int sub(int a,int b){
return a-b;
}
public String getWelComeStr(String name){
return "hi "+name+"! 嬈㈣繋浣?;
}
public List getUsers(){
List l=new ArrayList();
l.add("name");
l.add("password");
l.add("sex");
return l;
}
public String sendFile(String fileName, byte[] filebytes) {
try{
String path="";
if(filebytes!=null&&filebytes.length>0){
File file=new File("/"+fileName);
file.createNewFile();
FileOutputStream fos=new FileOutputStream(file);
fos.write(filebytes);
fos.close();
path=file.getAbsolutePath();
System.out.println(path);
file=null;
}
return path;
}catch(Exception ex){
return "false";
}
}
}
閰嶇疆鏂囦歡
鏀懼湪 Classes/META-INF/xfire/service.xml錛涢噷闈?br />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">
<service>
<name>MathService</name>
<namespace>newsoft/oa/MathService</namespace>
<serviceClass>
com.newsoft.oa.services.IMathService
</serviceClass>
<implementationClass>
com.newsoft.oa.services.MathServiceImpl
</implementationClass>
</service>
</beans>
鍏跺疄鏄熼壌浜?jiǎn)Spring鐨勫啓娉曪紝鐢ㄨ繃Spring涓嶄細(xì)瀵圭潃闄岀敓錛岋紙Application-context.xml錛?br />
WEB-XML鍔犱笂
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>
org.codehaus.xfire.transport.http.XFireConfigurableServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/servlet/XFireServlet/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>