最近在做一个关于用友EAI开发的工作,由于系统是采用.NET开发的C/S架构的,由于MSXML在WinForm的系统中实例化会出现问题,该类用友传递EAI参数,于是将相关的实现过程改为.NET方式代码如下:
c#实现soap传递
/********************************************************************************************************************************************/
/*时间:2009-11-24*/
/*功能:实现和用友EAI的参数传递*/
/********************************************************************************************************************************************/
//与用友系统的业务逻辑类
ABC.UT6EAI.Application.ABC.UT6EAI.Implement.BusinessInvoke UT6BusinessInvoke = new ABC.UT6EAI.Application.ABC.UT6EAI.Implement.BusinessInvoke();
UT6BusinessInvoke.XmlModelTemplatePath ="D:\\Temp\\";
UT6BusinessInvoke.XmlModelPath = "D:\\XML\\";
UT6BusinessInvoke.StoreInOut("storeinout.Xml", "add", "1", "storeinout", ref bcStoreInOutHeader, ref bcStoreInOutEntry);
//实现与EAI的XML信息交互
UT6BusinessInvoke.XmlModelTemplatePath ="D:\\Temp\\";
UT6BusinessInvoke.XmlModelPath = "D:\\XML\\";
UT6BusinessInvoke.StoreInOut("storeinout.Xml", "add", "1", "storeinout", ref bcStoreInOutHeader, ref bcStoreInOutEntry);
//实现与EAI的XML信息交互
System.Xml.XmlDocument dom = new XmlDocument();
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(http://***.***.*.*/u8eai/import.asp);
myRequest.Method = "POST";
myRequest.ContentType = @"text/xml;charset=utf-8";
dom.Load(UT6BusinessInvoke.XmlModelTemplatePath + "StoreInOut.Xml");
System.IO.MemoryStream ms = new System.IO.MemoryStream();
dom.Save(ms);
byte[] bytes = ms.ToArray();
myRequest.ContentLength = bytes.Length;
System.IO.Stream s = myRequest.GetRequestStream();
s.Write(bytes, 0, bytes.Length);
s.Close();
System.IO.StreamReader sr = new System.IO.StreamReader(myRequest.GetResponse().GetResponseStream());
String retXml = sr.ReadToEnd();
sr.Close();
dom = new XmlDocument();
dom.LoadXml(retXml);
MessageBox.Show(dom.DocumentElement.GetAttribute("dsc").ToString());
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(http://***.***.*.*/u8eai/import.asp);
myRequest.Method = "POST";
myRequest.ContentType = @"text/xml;charset=utf-8";
dom.Load(UT6BusinessInvoke.XmlModelTemplatePath + "StoreInOut.Xml");
System.IO.MemoryStream ms = new System.IO.MemoryStream();
dom.Save(ms);
byte[] bytes = ms.ToArray();
myRequest.ContentLength = bytes.Length;
System.IO.Stream s = myRequest.GetRequestStream();
s.Write(bytes, 0, bytes.Length);
s.Close();
System.IO.StreamReader sr = new System.IO.StreamReader(myRequest.GetResponse().GetResponseStream());
String retXml = sr.ReadToEnd();
sr.Close();
dom = new XmlDocument();
dom.LoadXml(retXml);
MessageBox.Show(dom.DocumentElement.GetAttribute("dsc").ToString());
//保存返回的信息
dom.Save(UT6BusinessInvoke.XmlModelTemplatePath + "\\" + tdProductId.Text + ".xml");
dom.Save(UT6BusinessInvoke.XmlModelTemplatePath + "\\" + tdProductId.Text + ".xml");