testprovision.java

王朝java/jsp·作者佚名  2006-01-09
宽屏版  字体: |||超大  

//dsmpclient.exe 模拟xml发送

package provision;

import provision.*;

import javax.servlet.*;

import javax.servlet.http.*;

import javax.servlet.jsp.PageContext;

import java.io.*;

import org.apache.xerces.parsers.SAXParser;

import org.xml.sax.SAXException;

import org.xml.sax.XMLReader;

public class testprovision extends HttpServlet

{

public void doPost(HttpServletRequest req,HttpServletResponse resp)throws IOException,ServletException

{

ServletInputStream data=req.getInputStream();

DataInputStream in=new DataInputStream(data);

handle handle = new handle();

int c;

String getxml="";

while((c=in.read())!=-1)

{

// System.out.print((char)c);

getxml=getxml+(char)c;

}

BufferedWriter bf=new BufferedWriter(new FileWriter(new File("D:\\Tomcat\\webapps\\root\\WEB-INF\\test.xml")));

bf.write(getxml);

bf.flush();

bf.close();

System.out.println(getxml);

XMLReader r=new SAXParser();

r.setContentHandler(handle);

//try

//{

//}

String str="<?xml version=\"1.0\" ?>";

str=str+"<SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/">";

str=str+"<SOAP-ENV:Header>";

str=str+"<dsmp:TransactionID xmlns:dsmp=\"11111121121http://www.monternet.com/dsmp/schemas/">11111121121</dsmp:TransactionID></SOAP-ENV:Header>";

str=str+"<SOAP-ENV:Body><dsmp:SyncOrderRelationResp xmlns:dsmp=\"http://www.monternet.com/dsmp/schemas/">";

str=str+"<Version>1.5.0</Version>";

str=str+"<MsgType>SyncOrderRelationResp</MsgType>";

str=str+"<hRet>0</hRet>";

str=str+"</dsmp:SyncOrderRelationResp>";

str=str+"</SOAP-ENV:Body>";

str=str+"</SOAP-ENV:Envelope>";

PrintWriter out=resp.getWriter();

out.print(str);

out.flush();

out.close();

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有