zoukankan      html  css  js  c++  java
  • java客户端调用webService

    啥也不想说,以前使用的方法突然不行了。各种网搜(记得别忘记到jar包哦:axis.jar)

    看代码,第一种方式,也就是以前的方式:

    改方式不用表名参数名称

     1 public static String invokeStrTypeInMethod(String wsdl, String dataStr,String methodName) throws ServiceException, RemoteException{
     2         Service service = new Service();
     3         Call call = null;
     4         String result = null; 
     5         
     6         call = (Call) service.createCall();
     7 //        call.setOption("soap.wsdl_cache_enabled", "0");
     8         call.setTargetEndpointAddress(wsdl);
     9         call.setOperationName(methodName);//WSDL里面描述的接口名称
    10         call.addParameter("in", org.apache.axis.encoding.XMLType.XSD_DATE,
    11                 javax.xml.rpc.ParameterMode.IN);//接口的参数
    12         call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型 
    13         result = (String)call.invoke(new Object[]{dataStr});
    14         return result;
    15     }

    目前遇见的情况是:part scanPay was not recognized(Does it exist in service WSDL?)

    网搜过后,换了一种方式访问:

     1 public static String invokeHuanXunPayMethod(String huanXunEndpoint, String datas, String methodName,String methodParameterName) throws ServiceException, RemoteException {
     2         Service service = new Service();
     3         Call call = null;
     4         String result = null; 
     5         
     6         call = (Call) service.createCall();
     7         call.setTargetEndpointAddress(huanXunEndpoint);
     8         call.setOperationName(new QName(访问wsdl地址后的targetNamespace, methodName));
     9 //        call.setOperationName("insertProdutc");//WSDL里面描述的接口名称
    10         call.addParameter(methodParameterName, org.apache.axis.encoding.XMLType.XSD_STRING,
    11                 javax.xml.rpc.ParameterMode.IN);//接口的参数
    12         call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型 
    13 //        String result = WebServicesUtils.invokeStrTypeInMethod(endpoint, dataStr, "insertProdutc");
    14 //        System.out.println(dataStr);
    15         result = (String)call.invoke(new Object[]{datas});
    16         return result;
    17     }

    这种方式是要指定明确的域名,以及方法参数名称,好了;欢迎各位丢板砖提意见,谢谢!!

  • 相关阅读:
    LruCache 原理
    线程间通信, 进程间通信
    安卓 权限 规则
    android 捕获所有异常 未捕获的异常
    serializable parcelable
    android intent 传递 二进制数据
    apk安装 卸载 原理
    ARGB 8888 内存大小
    dalvik 基于 jvm 的改进
    查看 MySQL 数据库中每个表占用的空间大小
  • 原文地址:https://www.cnblogs.com/cunkouzh/p/6743637.html
Copyright © 2011-2022 走看看