500分征求用web service 代码, 不够可以再加。 就是要通过web service 去跟更改四个1-4表格的资料,请各位高手帮帮忙,我的毕业项目是写个web application, 大部分都已经做完了,我对web service 也不熟, 由于时间不够,才想在此请人帮忙写web service 这部分. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先给我500分,[email protected]联系邮箱! 用jdom www.jdom.org 下载 jdom.jarpackage com.sumgenius;import java.io.*;import org.jdom.*;import org.jdom.input.*;import org.jdom.output.*;import org.jdom.transform.*;import javax.xml.transform.*;import javax.xml.transform.stream.*;public class WXMLTest { public void WXMLTest(){ } public static void transform (String docname, String sheetname,String outfile) throws Exception { System.out.println("docname = " + new File(docname) ); System.out.println("sheetname = " + sheetname ); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new File(docname)); XSLTransformer transformer = new XSLTransformer(new File(sheetname)); Document doc2 = transformer.transform(doc); XMLOutputter outp = new XMLOutputter(Format.getPrettyFormat()); outp.output(doc2, new FileWriter(outfile)); } public static void test(String infile, String outfile)throws Exception{ SAXBuilder sb = new SAXBuilder(); //从文件构造一个Document,因为XML文件中已经指定了编码,所以这里不必了 Document doc = sb.build(new File(infile)); //加入一条处理指令 /* ProcessingInstruction pi = new ProcessingInstruction ("xml-stylesheet","href=\"bookList.html.xsl\" type=\"text/xsl\""); doc.addContent(pi); */ Element root = doc.getRootElement(); //得到根元素 java.util.List U_MAXs = root.getChildren(); //得到根元素所有子元素的集合 Element deck = (Element)U_MAXs.get(0); //得到第一个book元素 Element MDN = deck.getChild("MDN"); //得到指定的字元素 MDN.setText("13049303775"); String mobile = MDN.getValue(); System.out.println("mobile:" + mobile); deck.removeChild("EffectiveDate"); String indent = " "; boolean newLines = false; XMLOutputter outp = new XMLOutputter(indent,newLines,"UTF-8"); outp.output(doc, new FileWriter(outfile)); outp.output(doc, System.out); } } 调用的代码 String UrlString = "http://10.141.167.111:8080/web-services/BrokerWS?WSDL"; String nameSpaceUri = "http://10.141.167.111:8080/web-services/BrokerWS"; String serviceName = "BrokerWSService"; //String portName = "BrokerWS"; System.out.println("UrlString = " + UrlString); URL helloWsdlUrl = new URL(UrlString); ServiceFactory serviceFactory = ServiceFactory.newInstance(); Service service = serviceFactory.createService(helloWsdlUrl, new QName(nameSpaceUri, serviceName)); kfxtCall = service.createCall( new QName("BrokerWS"), "serveKfxt"); String re = (String) kfxtCall.invoke(new String[] {"001111"}); hibernate 双向1对多问题 在线等。 java调用script如何在页面上显示啊 http://ip.wen.la/ip.jsp?q=220.181.6.19&x=45&y=16截取其中的域名和网站名称 web service中tomcat服务器的问题 高手帮帮忙啊........ 高手救命!!!如何通过类的名称(字符串)产生类的实例 简单的 srtuts问题 只有我不会100分求解 hibernate的cascade选项的区别? java接口安全 如何配置JavaMail环境 手机短信接口的编写问题!
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.transform.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;public class WXMLTest {
public void WXMLTest(){
}
public static void transform (String docname, String sheetname,String outfile) throws Exception {
System.out.println("docname = " + new File(docname) );
System.out.println("sheetname = " + sheetname );
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new File(docname)); XSLTransformer transformer = new XSLTransformer(new File(sheetname));
Document doc2 = transformer.transform(doc); XMLOutputter outp = new XMLOutputter(Format.getPrettyFormat());
outp.output(doc2, new FileWriter(outfile));
} public static void test(String infile, String outfile)throws Exception{
SAXBuilder sb = new SAXBuilder();
//从文件构造一个Document,因为XML文件中已经指定了编码,所以这里不必了
Document doc = sb.build(new File(infile));
//加入一条处理指令
/*
ProcessingInstruction pi = new ProcessingInstruction
("xml-stylesheet","href=\"bookList.html.xsl\" type=\"text/xsl\"");
doc.addContent(pi);
*/
Element root = doc.getRootElement(); //得到根元素
java.util.List U_MAXs = root.getChildren(); //得到根元素所有子元素的集合
Element deck = (Element)U_MAXs.get(0); //得到第一个book元素
Element MDN = deck.getChild("MDN"); //得到指定的字元素
MDN.setText("13049303775");
String mobile = MDN.getValue();
System.out.println("mobile:" + mobile);
deck.removeChild("EffectiveDate");
String indent = " ";
boolean newLines = false;
XMLOutputter outp = new XMLOutputter(indent,newLines,"UTF-8");
outp.output(doc, new FileWriter(outfile));
outp.output(doc, System.out);
}
}
String UrlString =
"http://10.141.167.111:8080/web-services/BrokerWS?WSDL";
String nameSpaceUri = "http://10.141.167.111:8080/web-services/BrokerWS";
String serviceName = "BrokerWSService";
//String portName = "BrokerWS";
System.out.println("UrlString = " + UrlString);
URL helloWsdlUrl = new URL(UrlString);
ServiceFactory serviceFactory = ServiceFactory.newInstance(); Service service =
serviceFactory.createService(helloWsdlUrl,
new QName(nameSpaceUri, serviceName)); kfxtCall = service.createCall(
new QName("BrokerWS"), "serveKfxt"); String re = (String) kfxtCall.invoke(new String[] {"001111"});