service里面可以写dowhere

service里面可以写dowhere,第1张

可以。Service 一词多义 梳理之三

Service 使用,有用,有帮助 – 既可以指器件、车辆、机器等,也可以指人。 比如, be of service to others 对他人有帮助。The ship will be taken out of service within two years. 那艘船将在两年之内退役,也就是不再使用。

13) Service 检修,维护,维修,保养 – 对车辆、机械的服务。比如,a service engineer 维修技师。

14) Service (通常用单数)班车,车次 - 定期或定时前往特定地点的公共汽车、火车、轮船或飞机。比如,the cancellation of the 9:00 service to Shenzhen 9点开往深圳的班车取消

15) Services(用复数)服务站 - 高速公路边可加油、购物或用餐。Motorway services 高速公路服务站

16) Service 发球,发球方式 – 网球、羽毛球等。比如,Her service has improved. 她的发球有了提高。

17) Service 宗教礼仪,礼拜仪式 - 服务是在教堂举行的宗教仪式。比如,to hold / attend a service 举行 / 参加礼拜

18) Service 送达,执行 - 传票等

19) Service 国债利息

/***

* 概述:纯java方式访问远程WebService接口返回的xml格式的数据保存在本地

*/

public class DomXMLString{

private static String SERVICES_HOST = "www.webxml.com.cn"

//远程WebService接口url

private static String NETDATA_URL = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx/getRegionProvince"

//访问远程WebService接口返回的xml格式的数据保存在本地的绝对路径

private static String LOCAL_PC_SAVEFILE_URL = "E:dataTest/netDataToLocalFile.xml"

private DomXMLString(){}

public static void main(String[] args) throws Exception{

Document document = getProvinceCode(NETDATA_URL)

helloOK(document, LOCAL_PC_SAVEFILE_URL)

}

/*返回一个Document对象*/

public static Document getProvinceCode(String netXMLDataURL){

Document document = null

DocumentBuilderFactory documentBF = DocumentBuilderFactory.newInstance()

documentBF.setNamespaceAware(true)

try{

DocumentBuilder documentB = documentBF.newDocumentBuilder()

InputStream inputStream = getSoapInputStream(netXMLDataURL) //具体webService相关

document = documentB.parse(inputStream)

inputStream.close()

}catch(DOMException e){

e.printStackTrace()

return null

}catch(ParserConfigurationException e){

e.printStackTrace()

return null

}catch (SAXException e){

e.printStackTrace()

return null

}catch(IOException e){

e.printStackTrace()

return null

}

return document

}

/*返回InputStream对象*/

public static InputStream getSoapInputStream(String url){

InputStream inputStream = null

try{

URL urlObj = new URL(url)

URLConnection urlConn = urlObj.openConnection()

urlConn.setRequestProperty("Host", SERVICES_HOST) //具体webService相关

urlConn.connect()

inputStream = urlConn.getInputStream()

}catch(MalformedURLException e){

e.printStackTrace()

}catch(IOException e){

e.printStackTrace()

}

return inputStream

}

/*访问远程(WebService)xml数据后返回的xml格式字符串并生成为本地文件*/

public static void helloOK(Document document, String savaFileURL){

TransformerFactory transF = TransformerFactory.newInstance()

try{

Transformer transformer = transF.newTransformer()

DOMSource source = new DOMSource(document)

transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8")

transformer.setOutputProperty(OutputKeys.INDENT, "YES")

PrintWriter pw = new PrintWriter(new FileOutputStream(savaFileURL))

StreamResult result = new StreamResult(pw)

transformer.transform(source, result)

System.out.println("生成xml文件成功!")

}catch(TransformerConfigurationException e){

System.out.println(e.getMessage())

}catch(IllegalArgumentException e){

System.out.println(e.getMessage())

}catch(FileNotFoundException e){

System.out.println(e.getMessage())

}catch(TransformerException e){

System.out.println(e.getMessage())

}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11867472.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存