友情链接1:21点 足球投注 投注网 明升体育 hg0088 葡京赌场 网上赌球 诈金花 澳门金沙网址 澳门银河网址 澳门银河 澳门银河官网 银河官网 威尼斯人 澳门威尼斯人 澳门威尼斯人官网 威尼斯人官网 金沙 澳门金沙 澳门金沙官网 金沙官网 现金网 赌球网 全讯网 明升国际 足球开户 ******官网 ******网址 现金赌博 澳门现金网 ******官方网站

WebService | Mingo's Blog
鏃ュ織鏍囩锛歐ebService

Java Webservice涔媂Fire鐨勫鎴风璋冪敤

鏃堕棿锛2012骞03鏈12鏃浣滆咃細Mingo琚洿瑙備簡锛14,696 娆璇勮娆℃暟锛2

鍓嶉潰鎴戜滑璇村埌Java Webservice涔媂Fire寤虹珛鏈嶅姟鍣ㄧ锛岃繖閲屾垜浠湅鐪嬫庝箞鍦ㄥ鎴风璋冪敤Webservice鐨勪袱绉嶆柟寮
涓銆侀氳繃鏈嶅姟绔彁渚涚殑鎺ュ彛绫昏繘琛岃皟鐢ㄣ
浠g爜濡備笅锛

package com.xfire.client;

import java.net.MalformedURLException;
import java.util.List;

import org.codehaus.xfire.XFire;
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 com.xfire.domain.Person;
import com.xfire.spring.IPersonService;

public class PojoInvokeClient {

  public static void main(String[] args) {
        Service serviceModel = new ObjectServiceFactory().create(IPersonService.class);
        XFire xfire = XFireFactory.newInstance().getXFire();
        XFireProxyFactory factory = new XFireProxyFactory(xfire);
        String serviceUrl = "http://127.0.0.1:8080/xfire/services/PersonService";
        IPersonService client = null;
        try {
              client = (IPersonService) factory.create(serviceModel, serviceUrl);
        } catch (MalformedURLException e) {
              System.out.println("Client call webservice has exception: "+ e.toString());
        }
        String result1 =client.sayHello("寮犱笁");
  }
}

浜屻佺洿鎺ラ氳繃url璋冪敤, 涓嶇敤瀹㈡埛绔彁渚涙帴鍙g被銆

package com.xfire.client;

import java.net.MalformedURLException;
import java.net.URL;

import org.codehaus.xfire.client.Client;

public class UrlInvokeClient {

  public static void main(String[] args) {
    Client client = null;
    try {
      client = new Client(new URL("http://127.0.0.1:8080/xfire/PersonService.ws?wsdl"));
      Object[] result1 = client.invoke("sayHello", new Object[] {"寮犱笁"});
      System.out.println(result1[0]);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

 

鏍囩锛,,鍒嗙被锛Java缂栫▼

Java WebService 涔媂Fire寤虹珛鏈嶅姟鍣ㄧ

鏃堕棿锛2012骞03鏈09鏃浣滆咃細Mingo琚洿瑙備簡锛9,348 娆璇勮娆℃暟锛0

1銆侀鍏堜笅杞芥墍闇瑕佺殑xfire鏀寔搴搙fire-distribution-1.2.6.zip锛屼笅杞藉湴鍧锛涓嬭浇涓 聽聽 涓嬭浇浜

2銆佺敤eclipse鏂板缓涓涓猈eb宸ョ▼銆傚鍏ユ敮鎸佸簱涓璴ib涓嬬殑鎵鏈夊寘鍜寈fire-all-1.2.6.jar鍒版垜浠伐绋嬬殑lib鐩綍涓嬨

3銆佷慨鏀筗eb宸ョ▼涓嬬殑web.xml鏂囦欢, 鍔犲叆浠ヤ笅浠g爜鍗冲彲

 

<servlet>
   <servlet-name>XFireServlet</servlet-name>
   <display-name>XFire
    Servlet</display-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>

4銆佸缓绔嬩竴涓櫘閫氱被鐢ㄤ簬鏄犲皠瀵瑰簲web鏈嶅姟涓句緥濡備笅:

public class BeanService {

  public String sayHello(String name) {
    return "浣犲ソ:"+ name;
  }
}

5銆佸湪宸ョ▼鐨剆rc涓嬪缓/src/META-INF/xfire/services.xml鏂囦欢,鍐呭濡備笅:

<beans>
 <service xmlns="http://xfire.codehaus.org/config/1.0">
  <name>BeanService</name>
  <namespace>http://xiaozhong/BeanServices</namespace>
  <serviceClass>com.xfire.services.BeanService</serviceClass>
 </service>
</beans>

6銆佸彂甯冨苟鍚姩鏈嶅姟鍣ㄣ傝闂http://localhost:8080/xfire/services灏卞彲浠ョ湅鍒版垜浠綋鍓嶅伐绋嬩腑鏈嶅姟鐨勫垪琛ㄣ傜偣鍑诲悗闈㈢殑wsdl灏卞彲浠ョ湅鍒版湇鍔$殑wsdl鏂囦欢浜嗐

 

 

 

鏍囩锛,,鍒嗙被锛Java缂栫▼