LoadRunner中使用java协议发送webservice请求

需要引入的jar包:

jdom.jar、wsdl4j-1.6.1.jar、xfire-all-1.2.6.jar、XmlSchema-1.1.jar

 

代码:

/*
 * LoadRunner Java script. (Build: _build_number_)
 * 
 * Script Description: 
 *                     
 */

import lrapi.lr;
import java.util.*;
import java.lang.*;
import org.codehaus.xfire.client.Client;
import java.net.URL;
import java.net.MalformedURLException;

public class Actions
{
	public int init() throws Throwable {
         
	    return 0;
	}//end of init


	public int action() throws Throwable {
          Client client = null;

    try {

      client = new Client(new URL("http://127.0.0.1:8080/xx/xx/xx?wsdl"));

      Object[] result1 = client.invoke("xx", new Object[]{"{\"xx\":\"123\",\"xx\":\"1\", \"xx\":{\"xx\":\"12345678\", \"xx\":\"12345678\", \"xx\":\"123456\", \"xx\":\"321\",\"xx\":\"123456\"} }"});

      System.out.println(result1[0]);

    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }


		return 0;
	}//end of action


	public int end() throws Throwable {
		return 0;
	}//end of end
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值