Java使用SOAP获取webservice实例解析

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Java使用SOAP获取webservice实例解析1.webservice提供方:。参数截图如下图:[]点击前面的网址,查看对应参数信息。3.Java程序程序需要引用:importjava.io.*;importjava.net.*;importjava.util.Vector;StringurlString=;StringxmlFile=QQOnlineService.XML;StringsoapActionString=;URLurl=newURL(urlString);HttpURLConnectionhttpConn=(HttpURLConnection)url.openConnection();;FilefileToSend=newFile(xmlFile);byte[]buf=newbyte[(int)fileToSend.length()];newFileInputStream(xmlFile).read(buf);httpConn.setRequestProperty(Content-Length,String.valueOf(buf.length));httpConn.setRequestProperty(Content-Type,text/xml;charset=utf-8);httpConn.setRequestProperty(soapActionString,soapActionString);httpConn.setRequestMethod(POST);httpConn.setDoOutput(true);httpConn.setDoInput(true);OutputStreamout=httpConn.getOutputStream();out.write(buf);out.close();InputStreamReaderisr=newInputStreamReader(httpConn.getInputStream(),utf-8);BufferedReaderin=newBufferedReader(isr);StringinputLine;BufferedWriterbw=newBufferedWriter(newOutputStreamWriter(newFileOutputStream(result.xml)));while((inputLine=in.readLine())!=null){System.out.println(inputLine);bw.write(inputLine);bw.newLine();}bw.close();in.close();说明:QQOnlineService.XML文件的内容就是上面截图中的请求xml字符串部分。以上由网友提供,QQ:279806210

1 / 2
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功