[Java] http请求.NET开发的webservice接口(AXIS) →→→→→进入此内容的聊天室

来自 , 2019-08-07, 写在 Java, 查看 128 次.
URL http://www.code666.cn/view/66be31e4
  1. /**
  2.      *  AXIS 调用 .NET开发的wbservice接口
  3.      * @param endPointAddr  webservice接口路径
  4.      * @param nameSpace  nameSpace 就是你用浏览器打开WSURl路径加上?wsdl,即http://xxx/SendWebService.asmx?wsdl 中的targetNamespace属性值
  5.      * @param method  调用的方法名
  6.      * @param params  参数名称数组
  7.      * @param values  参数值数组
  8.      * @return
  9.      */
  10.     public static Map axisEndPoint( String endPointAddr, String nameSpace, String method, String[] params, Object[] values)  {
  11.         Map result = null;
  12.         Schema schema = null;
  13.         try {
  14.             //创建一个服务
  15.             Service service = new Service();
  16.             //建立服务调用实例
  17.             Call call = ( Call ) service.createCall();
  18.             //设定调用路径
  19.             call.setTargetEndpointAddress( new URL( endPointAddr ) );
  20.             call.setUseSOAPAction(true);
  21.             //设定调用方法
  22.             call.setOperationName( new QName( nameSpace, method ) );
  23.             call.setSOAPActionURI( nameSpace + method );
  24.             call.setReturnType( XMLType.XSD_SCHEMA );
  25.             for (String param : params) {
  26.                 call.addParameter( new QName( nameSpace, param ), XMLType.XSD_STRING, ParameterMode.IN );
  27.             }
  28.             schema = (Schema) call.invoke(values);
  29.  
  30.             //暂时不考虑返回值
  31. //            MessageElement[] msgele = schema.get_any();
  32. //            List<MessageElement> msgElmtHead = msgele[0].getChildren();
  33. //            // 消息头,DataSet对象
  34. //            result = new HashMap<>();
  35. //            for (MessageElement element : msgElmtHead) {
  36. //                result.put(element.getName(), element.getValue());
  37. //            }
  38.         } catch ( Exception e ) {
  39.             e.printStackTrace();
  40.             result = null;
  41.         }
  42.         return result;
  43.     }
  44.  
  45. /*依赖
  46.  
  47. <!-- axis 1.4 jar start -->
  48.         <dependency>
  49.             <groupId>org.apache.axis</groupId>
  50.             <artifactId>axis</artifactId>
  51.             <version>1.4</version>
  52.         </dependency>
  53.         <dependency>
  54.             <groupId>commons-discovery</groupId>
  55.             <artifactId>commons-discovery</artifactId>
  56.             <version>0.2</version>
  57.             <exclusions>
  58.                 <exclusion>
  59.                     <groupId>commons-logging</groupId>
  60.                     <artifactId>commons-logging</artifactId>
  61.                 </exclusion>
  62.             </exclusions>
  63.         </dependency>
  64.         <dependency>
  65.             <groupId>org.apache.axis</groupId>
  66.             <artifactId>axis-jaxrpc</artifactId>
  67.             <version>1.4</version>
  68.         </dependency>
  69.         <dependency>
  70.             <groupId>org.apache.axis</groupId>
  71.             <artifactId>axis-saaj</artifactId>
  72.             <version>1.4</version>
  73.         </dependency>
  74.         <!-- axis 1.4 jar end -->
  75. */

回复 "http请求.NET开发的webservice接口(AXIS)"

这儿你可以回复上面这条便签

captcha