加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

网上WebService测试及使用

发布时间:2020-12-17 01:07:20 所属栏目:安全 来源:网络整理
导读:?The original website: http://longdick.iteye.com/blog/275529 网上有一些网站提供的WebService,可用作测试。如下地址就是一个提供英汉互译的WebService ? Endpoint: http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx Disco: http://www.
?The original website: http://longdick.iteye.com/blog/275529

网上有一些网站提供的WebService,可用作测试。如下地址就是一个提供英汉互译的WebService

?

Endpoint: http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx


Disco: http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx?disco


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

?

?

你可以直接在浏览器地址栏里输入:

http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx/getEnCnTwoWayTranslator?Word=hello

就能得到一个得到调用的xml格式的结果,这里getEnCnTwoWayTranslator是方法名,Word是参数名,如果你想汉译英的话就需要传递中文参数,但是你不能直接?? Word=你好??? 这样传中文参数,要先转换成unicode格式,这样才能作为url参数正常传递,就像这样:

http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx/getEnCnTwoWayTranslator?Word=%u4F60%u597D

?

?

你如果有xml处理工具的话,比如xmlspy这种,你可以根据WSDL地址直接构造一个soap协议封装的xml发送给服务端,代码可能向这种样子:

Xml代码

?

  1. <?xml?version="1.0"?encoding="utf-8"???>??
  2. <SOAP-ENV:Envelope?xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"? ??
  3. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"? ??
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"??
  5. xmlns:xsd="http://www.w3.org/2001/XMLSchema">??
  6. ??
  7. ????<SOAP-ENV:Body>??
  8. ???? ??
  9. ????????<m:getEnCnTwoWayTranslator?xmlns:m="http://WebXml.com.cn/">??
  10. ????????????<m:Word>hello</m:Word>??
  11. ????????</m:getEnCnTwoWayTranslator>??
  12. ????</SOAP-ENV:Body>??
  13. </SOAP-ENV:Envelope>??

?

如上soap xml发送英文参数没问题,但是发送中文参数就不能正常识别,这时候我们可以把编码方式改为utf-16,这样就能正常发送中文了。

<?xml version="1.0" encoding="utf-16"? ?>

(注:直接设置成GBK或GB2312都不成功,不知为何)

?

?

http://www.webxml.com.cn这个网站上还有不少其他的测试用WebService,大家可以去看看。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读