java调用C#SOAP

java后台调用例子:

public static void main(String[] args) {

    String url = "http://192.168.0.119/WebServices.asmx";//SOAP  地址

    String namespace="http://tempuri.org/";//namespace名称

    String method="method";//方法名称

    String parameter=“参数内容”;//方法中的参数(方法中的参数可能为多个,此例子为一个)

    callSoapService(url, namespace, method, new Object[]{parameter});//new Object[]{parameter}为传入的参数,多个参数为:new Object[]{parameter,parameter2,parameter3......}

}

public static Object callSoapService(String serviceUrl ,String nameSpace,String methodName, Object[] paremateArrs){

        String endPoint = serviceUrl;
        String actionUrl=nameSpace+methodName;
        Object returnObj = null;
        try{
            Service service = new Service();
            Call call = null;
            call = (Call)service.createCall();
            QName qName = new QName(nameSpace,methodName);
            call.setOperationName(qName);
            call.setSOAPActionURI(actionUrl);
  call.addParameter(new QName(nameSpace,"参数名称"), org.apache.axis.encoding.XMLType.XSD_STRING,             javax.xml.rpc.ParameterMode.IN);//将参数放入其中,(此例子参数为一个,若参数为多个可以多次call.addParameter......)
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
            call.setTargetEndpointAddress(new URL(endPoint));
            returnObj = call.invoke(paremateArrs);
        }catch(Exception ie){
            ie.printStackTrace();
        }
        System.out.println(returnObj);
        return returnObj;
    }  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值