WebService 接口接收数据 - TOMMYHU - 专注互联网开发及运营技术,提供相关资料及软件下载,奇趣网络时事评论!
May 31

WebService 接口接收数据 不指定

tommyhu , 22:10 , ASP.NET , Comments(0) , Trackbacks(0) , Reads(7600) , Via Original Large | Medium | Small
WebService 接口接收数据
// GetinfoData数据接收 webservice写法
  /// <summary>
  /// (接收端口)接收信息
  /// 接收程序建议根据XML的标识来判断数据项进行解析
  /// 即根据XML里定义的标识来判断什么样的数据,针对不同的数据进行不同的解析
  /// </summary>
  /// <param name="strXML">xml字符串</param>
  /// <param name="MessageID">BizTalk生成的唯一值,可以用也可以不用</param>
  /// <returns>返回OK说明接收数据成功,否则接收数据失败</returns>
  [WebMethod]
  public string GetInfoData(string strXML,string username,string userpwd)
  {
   string title = "";
   string mailBoxId = "";
   string name = "";
   string mailType = "";
   string content = "";
   string sendTime = "";
   string email = "";
   string phone = "";
   string address = "";
   string replyContent = "";
   string replyTime = "";
   string Status_Admin = "";
   string AllowPublish = "";
   if(CheckUser(username,userpwd) == false)
    return "用户身份验证失败!";
   XmlDataDocument xmlDoc=new XmlDataDocument();
            //xmlDoc.Load("d:\\ImportData.xml");
   xmlDoc.LoadXml(strXML);
   XmlNodeList topM=xmlDoc.DocumentElement.ChildNodes;
   foreach(XmlElement element in topM)
   {
    if(element.Name.ToLower()=="mail")
    {
     //得到根节点mail的子节点
     XmlNodeList nodelist=element.ChildNodes;
     if (nodelist.Count >0 )
     {
      #region 遍历元素值
      foreach(XmlElement el in nodelist)//读元素值
      {
       switch(el.Name.ToLower())
       {
        case "title":
         title = el.InnerText;
         break;
        case "mailboxid":
                                  mailBoxId = el.InnerText;
         break;
        case "sendname":
         name = el.InnerText;
            break;
        case "mailtype":
                                    mailType = el.InnerText;
         break;
        case "content":
         content = el.InnerText;
         break;
        case "sendtime":
                                    sendTime = el.InnerText;
         break;
        case "email":
         email = el.InnerText;
         break;
        case "phone":
         phone = el.InnerText;
         break;
        case "address":
         address = el.InnerText;
         break;
        case "replycontent":
         replyContent = el.InnerText;
         break;
        case "replytime":
         replyTime = el.InnerText;
         break;
        case "statusadmin":
         Status_Admin = el.InnerText;
         break;
        case "allowpublish":
         AllowPublish = el.InnerText;
         break;
       }
      
      }
      #endregion
      if(AddMail(title,mailBoxId,name,mailType,content,sendTime,email,phone,address,replyContent,replyTime,Status_Admin,AllowPublish)==false)
       return "失败!";
     }
    }
    
   }
   return "OK";
  
  }
▲返回顶部
相关日志(relate log)

Add a comment

Nickname

emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot