//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();
}
}