锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
3) 鍒涘緩services.xml騫舵妸瀹冩斁鍒癢EB-INF/classes/META-INF/xfire鐩綍涓嬶紝榪欐槸榛樿鐨勫仛娉?涔熷彲浠ュ皢services.xml鐨勮礬寰勯厤緗埌web.xml鏂囦歡涓?/p>
4) 灝哫Fire鍜屽叾瀹冪涓夋柟搴撴坊鍔犲埌Web搴旂敤鐨刉EB-INF/lib鐩綍涓嬨?/p>
FAQ
1) Weblogic8.1涓簲鐢╔Fire錛屽惎鍔╳ls鏃訛紝鍑虹幇java.lang.NoSuchMethodError鐨勮В鍐沖姙娉曘?br> 棣栧厛錛屽皢XFire鎻愪緵鐨凲Name JAR錛坬name.jar)鏀捐繘WEB-INF/lib鐩綍涓嬨傜劧鍚庯紝灝唚eblogic.xml鏂囦歡鏀懼埌WEB-INF涓嬨?br>weblogic.xml鐨勫唴瀹逛負錛?/p>
鍏蜂綋鐨勮緇嗚В璇達紝璇風湅XFire鐨刄ser's Guide.
鎶宸?br>1. 濡傛灉Web Services鐨勬柟娉曠殑鍙傛暟鏄疌ollections錛岄偅灝遍渶瑕佸緩涓涓狹apping鏂囦歡錛岃屼笖Mapping鏂囦歡鐨勫懡鍚嶄負className.aegis.xml錛屽茍涓斾笌class鏀懼湪鍚屼竴涓猵ackage涓嬨?br>濡傦細
public interface IConstraceSerice {
boolean editConstraceInfo(List aList);
}
Mapping鏂囦歡濡備笅錛欼ConstraceService.aegis.xml
<?xml version="1.0" encoding="utf-8"?>
<mappings>
<mapping>
<method name="editConstraceInfo">
<parameter index="0" componentType="java.lang.String"/>
</method>
</mapping>
</mappings>
<parameter index="0" componentType="java.lang.String"/>琛ㄧず絎竴涓弬鏁幫紝閲岄潰瀹為檯鍊肩殑綾誨瀷,榪欓噷瀹為檯鍊肩殑綾誨瀷鏄痡ava.lang.String.
濡傛灉鏄竴涓狫avaBean,濡俢om.test.TestBean,閭d互灝辮鍐欐垚<parameter index="0" compentType="com.test.TestBean"/>
2. 濡傛灉榪斿洖綾誨瀷鏄疞ist鎴朚ap錛屽茍涓旈噷闈㈠瓨鏀劇殑鏄嚜瀹氫箟綾葷殑璇濓紝鍒欓渶瑕佸鍔犱竴涓浜庢湇鍔℃帴鍙g殑閰嶇疆鏂囦歡銆傝鏂囦歡鐨勫懡鍚嶈鍒欐槸銆鎺ュ彛鏂囦歡鍚?aegis.xml銆備緥濡傛帴鍙f槸UserService.java鐨勮瘽錛屽垯姝ら厤緗枃浠跺懡鍚嶄負UserService.aegis.xml銆傛敞鎰忔閰嶇疆鏂囦歡欏諱笌鎺ュ彛鏀懼湪鍚屼竴鐩綍涓嬮潰銆?br><?xml version="1.0" encoding="UTF-8"?>
<mappings>
<mapping >
<method name="getUsers">
<return-type componentType="com.test.domain.User"/>
</method>
</mapping>
</mappings>
getUsers鏂規硶榪斿洖綾誨瀷鏄疞ist錛岄噷闈㈣鐨刄ser瀵硅薄銆傚浜庤繖縐嶇被鍨嬬殑鏂規硶錛屽湪閰嶇疆鏂囦歡涓弿榪頒簡瀹冪殑榪斿洖鍊肩被鍨嬨?/p>
濡傛灉榪斿洖鐨勭被鍨嬫槸Map鐨勮瘽錛屽仛娉曞拰List涓鏍楓備絾瀹氫箟鐨勭被鍨嬶紝鏄疢ap涓殑Value閮ㄥ垎錛屽茍涓旇繖鏍風殑璇濓紝Map涓璙alue鎵瀛樻斁鐨勫璞″氨蹇呴』鍏ㄩ儴鏄悓涓縐嶇被鍟︺?/p>
涓嬮潰緇欏嚭涓涓緇嗙殑渚嬪瓙錛?br>1錛夋湇鍔℃帴鍙?
public interface MyService2
{
boolean getInfo();
Collection getCollection(); //method 1
Collection getCollection(int id); //method 2
Collection getCollection(String id); //method 3
Collection getCollectionForValues(String id, Collection c); //method 4
Collection getCollectionForValues(int value, Collection c); //method 5
}
2) Mapping鏂囦歡鍐呭:
<mappings>
<mapping>
<!-- mapping 1 -->
<method name="getCollection">
<return-type componentType="java.lang.Double"/>
</method>
<!-- mapping 2 -->
<method name="getCollection">
<return-type componentType="java.lang.Float"/>
<parameter index="0" class="int"/>
</method>
<!-- mapping 3 -->
<method name="getCollectionForValues">
<return-type componentType="java.math.BigDecimal"/>
</method>
<!-- mapping 4 -->
<method name="getCollectionForValues">
<parameter index="0" class="java.lang.String"/>
<parameter index="1" componentType="java.util.Date"/>
</method>
<!-- mapping 5 -->
<method name="getCollectionForValues">
<return-type componentType="java.util.Calendar"/>
<parameter index="0" class="int"/>
<parameter index="1" componentType="java.lang.Bit"/>
</method>
</mapping>
</mappings>
3. 濡傛灉涓涓柟娉曠殑榪斿洖綾誨瀷鏄竴涓狫avaBean,鑰岃繖涓狫avaBean褰撲腑鍙堝瓨鍦–ollections,閭d箞灝遍渶瑕佸畾涔変竴涓笌JavaBean鐩稿叧鐨凪apping鏂囦歡,鏂囦歡鍚嶈涓嶫avaBean鍚嶇浉鍚?濡?User.aegis.xmll,騫朵笖涓嶫avaBean鏀懼湪鍚屼竴涓洰褰?
渚嬪瓙:
1) 鏈嶅姟鎺ュ彛
public interface IYMServiceFacade {
User getUser();
}
2) JavaBean
public class User {
private Strirng userName;
// 榪欓噷鏄竴涓狢ollection
private Set rooms;
.....
.....
}
3) Mapping鏂囦歡(User.aegis.xml)
<?xml version="1.0" encoding="utf-8"?>
<mappings>
<mapping>
<property name="rooms" componentType="com.powerunion.ymservice.dto.Room"/>
</mapping>
</mappings>
浠嬬粛:<property name="rooms" componentType="com.powerunion.ymservice.dto.Room"/>
鍏朵腑鐨刵ame灞炴у氨鏄疛avaBean閲岄潰瀹氫箟鐨剅ooms,componentType涓婇潰鐨勭浉鍚?琛ㄧずCollections閲岀湡姝e瓨鍌ㄧ殑綾誨瀷.
娉細濡傛灉鏈嶅姟鎺ュ彛鐨勫弬鏁版垨鑰呰繑鍥犵被鍨嬫槸鍩烘湰綾誨瀷錛坕nt, float, double絳?灝變笉闇瑕佸垱寤篗apping鏂囦歡銆?br>璇︾粏鐨勪俊鎭XFire鐨刄ser's Guide.
4.濡傛灉Web Services鍜屽鎴風榪愯鍦ㄥ悓涓涓狫VM涓婏紝鍙互閫夋嫨浣跨敤鏈湴浼犺緭錛屽彲浠ュぇ騫呮彁鍗囨ц兘銆傚錛氫互涓嬫寚瀹氭湇鍔$URL鐨勮繖琛屻?br>String serviceUrl = "http://localhost:8080/YM/services/ContractService";
鏇挎崲涓?br>String serviceUrl = "xfire.local://ContractService";
5. 鐢╝nt task 鐢熸垚xfire 瀹㈡埛绔唬鐮?
鐢▁fire涓嶇鏄厤緗畐eb service錛岃繕鏄敓鎴愬鎴蜂唬鐮侀兘寰堟柟渚匡紟
鐢熸垚瀹㈡埛浠g爜鍙鍦ㄧ敤ant鐢熸垚灝卞彲浠ヤ簡錛?/p>
build.xml
浠g爜
<?xml version="1.0"?>
<project default="genfiles" basedir=".">
<property name="lib" value="WebRoot/WEB-INF/lib" />
<path id="myclasspath">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
<pathelement location="${genfiles}" />
</path>
<property name="code_path" value="src" />
<property name="wsdl_path" value="Echo1Service.xml" />
<property name="code_package" value="com.client" />
<target name="genfiles" description="Generate the files">
<taskdef name="wsgen" classname="org.codehaus.xfire.gen.WsGenTask" classpathref="myclasspath" />
<wsgen outputDirectory="${code_path}" wsdl="${wsdl_path}" package="${code_package}" binding="xmlbeans" />
</target>
</project>