WSDL测试webservice接口记录[亲测有效]

WSDL测试webservice接口记录[亲测有效]WSDL测试webservice接口记录 osc_sdo8al3q 2018/09/12 17:51 阅读数 104 收到一个事情,需要对接第三方API,对方给了个service,看了一下,原来是w…

WSDL测试webservice接口记录

WSDL测试webservice接口记录

2018/09/12 17:51
阅读数 104

收到一个事情,需要对接第三方API,对方给了个service,看了一下,原来是webservices的。

上一次测试webervice的接口,还是至少八九年前的时候了,这种相对比较老旧的也好久不在使用。

于是,简单搞了一下,从搭环境到测试完成,基本花了10来分钟,对比结果花点时间,也抽空简单记录一下。 

请求:

http://www.shuce.com.cn/services/CommService?wsdl

接口:call

参数:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.shuce.com.cn">
<soapenv:Header/>
<soapenv:Body>
<ser:call>
<ser:act>dscx_lz</ser:act>
<!--1 or more repetitions:-->
<ser:args>74481885-4244-47d9-aa51-88e2aabebdbc</ser:args>
<ser:args>cxveh</ser:args>
<ser:args>C372DD</ser:args>
<ser:args>02</ser:args>
</ser:call>    
</soapenv:Body>
</soapenv:Envelope>

 

返回:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<callResponse xmlns="http://service.shuce.com.cn">
<callReturn>{"ret":1,"clpp":"宝马牌","clxh":"BMW7202ES(BMWX1)","gcjk":"国产","zzg":"中国","zzcmc":"华晨宝马汽车有限公司","fdjxh":"N46B20E","hdzk":"5","ckg":"4477*1798*1577","csys":"棕","rlzl":"汽油","pl":"1995","gl":"122","cllx":"小型轿车","syxz":"非营运","ccdjrq":"20130917","zt":"正常","hbdbqk":"GB18352.3-2005(国Ⅳ阶段)","ccrq":"20130522","yxqz":"20190930","qzbfqz":"20991231"} </callReturn> </callResponse>
</soapenv:Body> </soapenv:Envelope>

 

json格式化结果:

{ "ret": 1, "clpp": "宝马牌", "clxh": "BMW7202ES(BMWX1)", "gcjk": "国产", "zzg": "中国", "zzcmc": "华晨宝马汽车有限公司", "fdjxh": "N46B20E", "hdzk": "5", "ckg": "4477*1798*1577", "csys": "棕", "rlzl": "汽油", "pl": "1995", "gl": "122", "cllx": "小型轿车", "syxz": "非营运", "ccdjrq": "20130917", "zt": "正常", "hbdbqk": "GB18352.3-2005(国Ⅳ阶段)", "ccrq": "20130522", "yxqz": "20190930", "qzbfqz": "20991231" }

WSDL测试webservice接口记录[亲测有效]

 

其他

后来,我看了一下别的wsdl:

http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl

做了一个测试,结果测试OK,简要也记录一下

request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://WebXml.com.cn/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:getCountryCityByIp>
         <!--Optional:-->
         <web:theIpAddress>115.239.210.27</web:theIpAddress>
      </web:getCountryCityByIp>
   </soapenv:Body>
</soapenv:Envelope>

response:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <getCountryCityByIpResponse xmlns="http://WebXml.com.cn/">
         <getCountryCityByIpResult>
            <string>115.239.210.27</string>
            <string>浙江省绍兴市 电信</string>
         </getCountryCityByIpResult>
      </getCountryCityByIpResponse>
   </soap:Body>
</soap:Envelope>

如果你想要尝试一下,进行一些测试,这里提供了一些wsdl,可以用来测试,可以试试。

 

所谓授之以鱼,不如授之以渔。这里也补上一些前提和方法:

下载地址:

官网:https://www.soapui.org/professional/soapui-pro.html

文件地址:http://cncspace.onlinedown.net/down/SoapUI-5.2.1-mac-bin.zip

下载地址:http://www.onlinedown.net/soft/177299.htm

下载之后的安装很简单,略过,简要提一下启动。如果用的是mac的话,这样启动:

启动命令:

cd /Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin ./soapui.sh

haodeMBP:bin hao$ pwd

/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin

haodeMBP:bin hao$ ls

SoapUI-Spashscreen.png installationcomplete.sh mockservicerunner.sh soapui-errors.log soapui.sh toolrunner.sh wargenerator.sh

actions listeners securitytestrunner.sh soapui-log4j.xml starter-page.html uninstallactiontrack.sh

ext loadtestrunner.sh soapui-5.2.1.jar soapui.log testrunner.sh updateinstallation.sh

haodeMBP:bin hao$ ./soapui.sh 

================================

=

= SOAPUI_HOME = /Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1

=

================================

Configuring log4j from [/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin/soapui-log4j.xml]

16:26:15,406 INFO  [DefaultSoapUICore] Creating new settings at [/Users/hao/soapui-settings.xml]

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

16:26:16,523 INFO  [PluginManager] 0 plugins loaded in 3 ms

16:26:16,523 INFO  [DefaultSoapUICore] All plugins loaded

Configuring log4j from [/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin/soapui-log4j.xml]

16:26:16,729 INFO  [DefaultSoapUICore] Creating new settings at [/Users/hao/soapui-settings.xml]

16:26:16,740 INFO  [PluginManager] 0 plugins loaded in 0 ms

16:26:16,740 INFO  [DefaultSoapUICore] All plugins loaded

16:26:23,688 INFO  [DefaultSoapUICore] Defaulting to native L&F for Mac OS X

16:26:23,740 INFO  [SoapUI] Used java version: 1.8.0_181

16:28:17,764 INFO  [SchemaUtils] Added default schema from file:/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin/soapui-5.2.1.jar!/com/eviware/soapui/resources/xsds/xop.xsd with targetNamespace http://www.w3.org/2004/08/xop/include

16:28:17,781 INFO  [SchemaUtils] Added default schema from file:/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin/soapui-5.2.1.jar!/com/eviware/soapui/resources/xsds/XMLSchema.xsd with targetNamespace http://www.w3.org/2001/XMLSchema

16:28:17,782 INFO  [SchemaUtils] Added default schema from file:/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin/soapui-5.2.1.jar!/com/eviware/soapui/resources/xsds/xml.xsd with targetNamespace http://www.w3.org/XML/1998/namespace

16:28:17,782 INFO  [SchemaUtils] Added default schema from file:/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin/soapui-5.2.1.jar!/com/eviware/soapui/resources/xsds/swaref.xsd with targetNamespace http://ws-i.org/profiles/basic/1.1/xsd

16:28:17,783 INFO  [SchemaUtils] Added default schema from file:/Users/hao/Downloads/SoapUI-5.2.1-mac-bin/SoapUI-5.2.1/bin/soapui-5.2.1.jar!/com/eviware/soapui/resources/xsds/xmime200505.xsd with targetNamespace http://www.w3.org/2005/05/xmlmime

可见启动之后,就打开了对应的应用程序窗口。

至于工具的使用,我向来觉得是不用看教程,任何工具拿上来随便点两下,就明白了,这个soapUI也是一样的。


 

其实方法这里已经写的很清楚了,而且没什么问题。照着操作即可。

以上是原创,下面这一段是摘录的。

测试操作步骤如下:

  (1)首先找到cxfwebservice.xml配置信息中地址,在浏览器中出入:http://127.0.0.1:8080/ssg?wsdl会生成文档说明,直接给要对接的用户即可

<jaxws:endpoint id="ssg" implementor="cn.exchange.cxf.DataExchangeWebServiceImpl" address="http://127.0.0.1:8080/ssg">
 </jaxws:endpoint>

  (2)使用soapUI测试接口:

  注意:在测试之前,要先开启接口项目

  ①在接口项目开启之后,打开工具soapUi,新建(file→create empty project),如下图所示:

WSDL测试webservice接口记录[亲测有效]

  ②右击工程project——add wsdl,如下图所示:

WSDL测试webservice接口记录[亲测有效]

  打开如下图的页面:

WSDL测试webservice接口记录[亲测有效]

  ③然后进入如下页面:(修改:应该双击”request1″)

WSDL测试webservice接口记录[亲测有效]

  双击”request1″出现如下的窗口:

WSDL测试webservice接口记录[亲测有效]

 

  ④在”?”号处输入相关的参数,点击运行,如果右侧空白没有出现错误的信息,说明接口方法可以使用

  测试失败,如下所示:(对于不同的项目,可能提示信息有所不同,要视情况而定,这里不是绝对的结果)

WSDL测试webservice接口记录[亲测有效]

  测试成功,如下图:(对于不同的项目,可能提示信息有所不同,要视情况而定,这里不是绝对的结果)
WSDL测试webservice接口记录[亲测有效]

 

可见,WSDL的测试相对比较简单,如果没接触过的话,花几分钟看下就会明白。

如上。

 

–20180912 15:49于沪 长宁白猫科技园

 

本文转载自:https://www.cnblogs.com/haochuang/p/9636315.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/6355.html

(0)
上一篇 2023-04-12
下一篇 2023-04-12

相关推荐

  • ubuntu安装phpstudy_php导入sql文件

    ubuntu安装phpstudy_php导入sql文件 默认安装的php不存在pdo扩展,因此在使用到的时候会报错,直接使用这个命令 apt-get install php-mysql 就可以成功安装pdo扩展 安装完数据库后需要导入sql语句,…

    2023-03-21
    140
  • 【赵强老师】在Spark SQL中读取JSON文件「建议收藏」

    【赵强老师】在Spark SQL中读取JSON文件「建议收藏」Spark SQL是Spark用来处理结构化数据的一个模块,它提供了一个编程抽象叫做DataFrame并且作为分布式SQL查询引擎的作用。为什么要学习Spark SQL?如果大家了解Hive的话,应该

    2023-02-14
    100
  • Oracle实例占用超高CPU排查[通俗易懂]

    Oracle实例占用超高CPU排查[通俗易懂]CPU主要功能:处理指令、执行操作、要求进行动作、控制时间、处理数据。 结合数据库实例CPU占用高,可能的原因是数据库在执行大量的操作(全表查询、大量排序等)。 由于公司没有DBA,遇到数据库问题只能

    2023-01-22
    105
  • Redis系列(七)Redis面试题[亲测有效]

    Redis系列(七)Redis面试题[亲测有效]Redis 系列: 1. ‘Redis系列(一)Redis入门’ 2. ‘Redis系列(二)Redis的8种数据类型’ 3. ‘Redis系列(三)Redis的事务和Spring Boot整合’ 4

    2023-02-28
    91
  • Python Tuple: 简单、快速、高效的数据结构

    Python Tuple: 简单、快速、高效的数据结构在编程中,数据结构是最重要的部分之一。虽然Python提供了多种内置的数据类型,但是Tuple是其中最值得关注的。Tuple是一个有序且不可修改的序列。

    2024-03-12
    31
  • Python的字符串计数方法应用与示例

    Python的字符串计数方法应用与示例在Python中,字符串计数是一个非常常见的操作。Python内置的字符串方法和模块中提供了各种字符串计数的方法,包括计算字符串中某个字符出现的次数、计算一个字符串在另一个字符串中出现的次数、计算字符串中某个子串出现的次数等。

    2024-02-05
    44
  • redis伪分布主从环境配置[亲测有效]

    redis伪分布主从环境配置[亲测有效]监控同一个Master的Sentinel会自动连接,组成一个分布式的Sentinel网络,互相通信并交换彼此关于被监视服务器的信息 下图中3个Sentinel监控着S1和它的2个Slave 配置: …

    2023-03-24
    99
  • Python初学者如何开始学习Python语言

    Python初学者如何开始学习Python语言随着计算机技术的发展,越来越多的人开始学习编程语言。而Python,作为一门简单易学,功能强大的编程语言,吸引了越来越多的初学者。那么,作为Python初学者,如何开始学习这门语言呢?下面,我们将从多个方面为大家详细阐述。

    2023-12-22
    66

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注