zoukankan      html  css  js  c++  java
  • java 调用C#webservice

    java调用C#的webservice   asmx

    备用!

    import java.rmi.RemoteException;

    import javax.xml.namespace.QName;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.rpc.ServiceException;
    import javax.xml.rpc.encoding.XMLType;

    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;

    public class Test {

    public static void test() {
    String url = "http://113.108.79.129:1126/GetInfo.asmx";
    String namespace = "http://tempuri.org/";
    String methodName = "GetCommAuthor";
    String soapActionURI = "http://tempuri.org/GetCommAuthor";

    Service service = new Service();
    Call call;
    try {
    call = (Call) service.createCall();

    call.setTargetEndpointAddress(url);
    call.setUseSOAPAction(true);
    call.setSOAPActionURI(soapActionURI);
    call.setOperationName(new QName(namespace, methodName));

    call.addParameter(new QName(namespace, "randkey"), XMLType.XSD_STRING, ParameterMode.IN);
    call.addParameter(new QName(namespace, "hashval"), XMLType.XSD_STRING, ParameterMode.IN);
    call.setReturnType(XMLType.XSD_STRING);

    String[] str = new String[2];
    str[0] = "1234";
    str[1] = "F84E09578B22FD015E6A6B47999FBCE1C6D4E90F";

    Object obj = call.invoke(str);
    System.out.println(obj);
    } catch (ServiceException e) {
    e.printStackTrace();
    } catch (RemoteException e) {
    e.printStackTrace();
    }
    }

    public static void main(String[] args) {
    Test.test();
    }
    }

  • 相关阅读:
    bzoj2818
    bzoj1901
    bzoj1010
    loj6277
    bzoj1001
    bzoj1787
    选项卡
    日期选择器
    去掉文本框的外边框
    bootstarp 模态框大小尺寸的控制
  • 原文地址:https://www.cnblogs.com/Zhong-Xin/p/8961284.html
Copyright © 2011-2022 走看看