java客户端调用webservice_java调用.net webservice的客户端实现

package com.smtic.travel.client;

import java.net.URL;

import javax.xml.namespace.QName;

import javax.xml.rpc.ParameterMode;

import javax.xml.rpc.encoding.XMLType;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

public class PassengerFlowClient implements IWebServiceClient {

private Log log = LogFactory.getLog(this.getClass());

private String url = "http://localhost/rt/Service.asmx";

private String user = "fwpt";

private String password = "fwpt";

private String strResult = "世博入口客流";

public String getData() {

String result = "<?xml version=\"1.0\" encoding=\"gbk\"?>";

Service service = new Service();

Call call = null;

try {

String ns = "http://tempuri.org/";

call = (Call) service.createCall();

call.setTargetEndpointAddress(new URL(url));

call.setOperationName(new QName(ns, "GetTrafficData"));

call.addParameter(new QName(ns, "strCustomID"), XMLType.XSD_STRING,

ParameterMode.IN);

call.addParameter(new QName(ns, "strPassword"), XMLType.XSD_STRING,

ParameterMode.IN);

call.addParameter(new QName(ns, "strResult"), XMLType.XSD_STRING,

ParameterMode.IN);

call.setUseSOAPAction(true);

call.setReturnType(XMLType.XSD_STRING);

call.setSOAPActionURI("http://tempuri.org/GetTrafficData");

result += (String) call.invoke(new Object[] { user, password,

strResult });

} catch (Exception e) {

log.error(e.getMessage());

e.printStackTrace();

}

return result;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值