iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >java调用webservice的.asmx接口的使用步骤
  • 623
分享到

java调用webservice的.asmx接口的使用步骤

2024-04-02 19:04:59 623人浏览 独家记忆

Python 官方文档:入门教程 => 点击学习

摘要

目录前言一、接口类型二、使用步骤1.访问方式2.导入的Maven前言 接触到一个.asmx结尾的WEBservice接口,为了增加记忆决定记录下来。 一、接口类型 已.asmx结尾的

前言

接触到一个.asmx结尾的WEBservice接口,为了增加记忆决定记录下来。

一、接口类型

已.asmx结尾的接口


例:接口地址:Http://IP地址/xxx/service/xxx/xxxx.asmx
	方法名:test
	参数类型:string 

二、使用步骤

1.访问方式

代码如下(示例):

controller类:


String s = clientUtil.test("http://IP地址/xxx/service/xxx/xxxx.asmx", "test","test");

调用类:


public static String test(String Url, String methodName, String str) throws Exception {
        String ref = null;
        // webService链接地址
        String url = Url;
        //获取域名地址,server定义的
        String soapaction = "http://tempuri.org/";
		
        Service service = new Service();
        try {
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(url);
            // 设置要调用哪个方法
            call.setOperationName(new QName(soapaction, methodName));
            // 设置要传递的参数名
           call.addParameter(new QName(soapaction,"str"),org.apache.axis.encoding.XMLType.XSD_STRING,
       javax.xml.rpc.ParameterMode.IN);
            // 提供标准类型 有addParameter就必须有setReturnType
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
            call.setUseSOAPAction(true);
            call.setSOAPActionURI(soapaction + methodName);
            // 调用方法并传递参数
			ref = (String) call.invoke(new Object[]{str});
           return ref;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ref;
    }

2.导入的maven

如下:


<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>
<dependency>
    <groupId>org.apache.axis</groupId>
    <artifactId>axis</artifactId>
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>axis</groupId>
    <artifactId>axis-jaxrpc</artifactId>
    <version>1.4</version>
</dependency>

参考:
[1]https://blog.csdn.net/qq_34302802/article/details/101197464

到此这篇关于java调用webservice的.asmx接口的文章就介绍到这了,更多相关java调用webservice接口内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: java调用webservice的.asmx接口的使用步骤

本文链接: https://www.lsjlt.com/news/135220.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作