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