webservice之获得中文、英文双向翻译
来源:互联网 发布:万能搬家软件下载 编辑:程序博客网 时间:2024/05/15 20:02
webservice地址:http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx?op=getEnCnTwoWayTranslator
soap协议:
SOAP 1.1以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /WebServices/TranslatorWebService.asmx HTTP/1.1Host: www.webxml.com.cnContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://WebXml.com.cn/getEnCnTwoWayTranslator"<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getEnCnTwoWayTranslator xmlns="http://WebXml.com.cn/"> <Word>string</Word> </getEnCnTwoWayTranslator> </soap:Body></soap:Envelope>HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Content-Length: length<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getEnCnTwoWayTranslatorResponse xmlns="http://WebXml.com.cn/"> <getEnCnTwoWayTranslatorResult> <string>string</string> <string>string</string> </getEnCnTwoWayTranslatorResult> </getEnCnTwoWayTranslatorResponse> </soap:Body></soap:Envelope>SOAP 1.2以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /WebServices/TranslatorWebService.asmx HTTP/1.1Host: www.webxml.com.cnContent-Type: application/soap+xml; charset=utf-8Content-Length: length<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <getEnCnTwoWayTranslator xmlns="http://WebXml.com.cn/"> <Word>string</Word> </getEnCnTwoWayTranslator> </soap12:Body></soap12:Envelope>HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: length<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <getEnCnTwoWayTranslatorResponse xmlns="http://WebXml.com.cn/"> <getEnCnTwoWayTranslatorResult> <string>string</string> <string>string</string> </getEnCnTwoWayTranslatorResult> </getEnCnTwoWayTranslatorResponse> </soap12:Body></soap12:Envelope>
代码如下:
private static void getEnCnTwoWayTranslator(String word) {try {String soapBindingAddress = "http://webservice.webxml.com.cn/webservices/TranslatorWebService.asmx";ServiceClient sender = new ServiceClient();EndpointReference endpointReference = new EndpointReference(soapBindingAddress);Options options = new Options();options.setAction("http://WebXml.com.cn/getEnCnTwoWayTranslator");options.setTo(endpointReference);sender.setOptions(options);OMFactory fac = OMAbstractFactory.getOMFactory();OMNamespace omNs = fac.createOMNamespace("http://WebXml.com.cn/","getEnCnTwoWayTranslator");OMElement data = fac.createOMElement("getEnCnTwoWayTranslator",omNs);String[] strs = new String[] { "Word" };String[] val = new String[] { word };for (int i = 0; i < strs.length; i++) {OMElement inner = fac.createOMElement(strs[i], omNs);inner.setText(val[i]);data.addChild(inner);}OMElement result = sender.sendReceive(data);System.out.println(result.toString());} catch (AxisFault ex) {ex.printStackTrace();}}
调用:
getEnCnTwoWayTranslator("你好");
getEnCnTwoWayTranslator("hello");
结果:
<getEnCnTwoWayTranslatorResponse xmlns="http://WebXml.com.cn/"><getEnCnTwoWayTranslatorResult><string>你好: [ n&#464 h&#462o ]</string><string>1. hello |
2. how are you |</string></getEnCnTwoWayTranslatorResult></getEnCnTwoWayTranslatorResponse>
<getEnCnTwoWayTranslatorResponse xmlns="http://WebXml.com.cn/"><getEnCnTwoWayTranslatorResult><string>hello: [ 'hel&#601u, he'l&#601u ]</string><string>int.(见面打招呼或打电话用语)喂,哈罗 |
词形变化:异体字:hullo 名词复数:hellos 动词过去式:helloed 过去分词:helloed 现在分词:helloing 第三人称单数:helloes |</string></getEnCnTwoWayTranslatorResult></getEnCnTwoWayTranslatorResponse>
- webservice之获得中文、英文双向翻译
- webservice之获得随机英文、数字
- 编写英汉双向翻译词典的WebService
- 英文的 "I" 中文怎么翻译
- 英文的 "I" 中文怎么翻译(转)
- 数字的翻译(英文到中文)
- python实现有道翻译英文转中文
- webservice之获得随机汉字
- 学习篇之英文文档翻译能力
- 翻译英文
- php 获得英文和中文混合的字数iconv_strlen
- 调用谷歌翻译实现英文转中文
- 特朗普 胜选演讲 全文翻译(中文+英文)
- 英文地址的翻译
- 英文地址的翻译
- 英文地址的翻译
- 英文标点符号翻译大全
- 英文标点符号翻译
- windows文件句柄修改
- AngularJS $resource RESTful example
- http长连接200万尝试及调优(好文章推荐阅读)
- hibernate分页排序问题
- 停滞了学习的进度,却开始了迷茫
- webservice之获得中文、英文双向翻译
- ios程序依赖的开源库管理软件-cocoapods介绍
- Linux死机解决办法
- 字符串中常常遇到的错误
- ListPopupWindow
- MAC系统使用教程,从零到高手使用进阶教程!必备增强软
- zxing源码分析——QR码部分
- js节点属性及使用说明
- A general iterated shinkage algorithm for non-convex sparse coding.