Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET XML
I have an e-commerce site and need to communicate with another system, then that system asked me to develop a system which will be receiving an xml file means they will be sending an xml file in this format :
Request sent from CompanyA to CompanyB(This is my e-commerce website)
<?xml version="1.0"?>
  <!DOCTYPE COMMAND PUBLIC "-//Ocam//DTD XML Command 1.0//EN" "xml/command.dtd">
    <COMMAND>
                <TYPE>PAYMENT</TYPE>
                <COMPANYNAME>Luku</COMPANYNAME>
                <CUSTOMERREFERENCEID>refernceNumber</CUSTOMERREFERENCEID>
                <MSISDN>msisdn</MSISDN>
                <AMOUNT></AMOUNT>
                <TXNID></TXNID>
                <STATUS></STATUS>
    </COMMAND>
and my system will parse that xml file and load it then reply to the system like this:
synchronous response sent from CompanyB back to CompanyA
<?xml version="1.0">
  <!DOCTYPE COMMAND PUBLIC "-//Ocam//DTD XML Command 1.0//EN" "xml/command.dtd">
    <COMMAND>
      <TYPE>GBPHANDLER</TYPE>
      <TXNID>BP120522.1117.C00001</TXNID>
      <REFID>1357</REFID>
      <RESULT>TS</RESULT>
      <ERRORCODE>ERR123</ERRORCODE>
      <FLAG>Y</FLAG>
      <CONTENT>Content For Sending SMS</CONTENT>
      <MSISDN>09899847486</MSISDN>
      <COMPANYCODE>Luku</COMPANYCODE>
    </COMMAND>
and for that I have using the following code as shown in the code below:
 
[WebMethod]
    public string COMMAND(string xml)
    {
        #region Load received xml and parse the values
        XmlDocument xdoc = new XmlDocument();
        xdoc.LoadXml(xml + Environment.NewLine);
        string TYPE = xdoc["COMMAND"].ChildNodes[0].InnerText;
        string COMPANYNAME = xdoc["COMMAND"].ChildNodes[1].InnerText;
        string CUSTOMERREFERENCEID = xdoc["COMMAND"].ChildNodes[2].InnerText;
        string MSISDN = xdoc["COMMAND"].ChildNodes[3].InnerText;
        string AMOUNT = xdoc["COMMAND"].ChildNodes[4].InnerText;
        string TXNID = xdoc["COMMAND"].ChildNodes[5].InnerText;
        string STATUS = xdoc["COMMAND"].ChildNodes[6].InnerText;
        #endregion
 
        string ERRORCODE = string.Empty;
        string RESULT = string.Empty;
        string FLAG = string.Empty;
        string CONTENT = string.Empty;
 
        StringBuilder sb = new StringBuilder();
        DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), "[GetCheckoutInfoTest]", CUSTOMERREFERENCEID,AMOUNT);
        if (ds.Tables[0].Rows.Count &gt; 0)
        {
            //assign the values of ERRORCODE,RESULT,FLAG,CONTENT when condition is true
            RESULT = "TS";
        }
        else
        {
             RESULT = "TF";
        }
 
        #region write the response xml
        XmlWriter writer = XmlWriter.Create(sb);
 
            writer.WriteStartDocument();
            writer.WriteStartElement("COMMAND");
 
            writer.WriteStartElement("TYPE");
            writer.WriteValue(TYPE);
            writer.WriteEndElement();
 
            writer.WriteStartElement("TXNID");
            writer.WriteValue(TXNID);
            writer.WriteEndElement();
 
            writer.WriteStartElement("REFID");
            writer.WriteValue(CUSTOMERREFERENCEID);
            writer.WriteEndElement();
 
         
 
            writer.WriteStartElement("ERRORCODE");
            writer.WriteValue(ERRORCODE);
            writer.WriteEndElement();
 
            writer.WriteStartElement("FLAG");
            writer.WriteValue(FLAG);
            writer.WriteEndElement();
 
            writer.WriteStartElement("MSISDN");
            writer.WriteValue(MSISDN);
            writer.WriteEndElement();
 
            writer.WriteStartElement("CONTENT");
            writer.WriteValue(CONTENT);
            writer.WriteEndElement();
 
            writer.WriteStartElement("COMPANYCODE");
            writer.WriteValue(COMPANYNAME);
            writer.WriteEndElement();
 
            writer.WriteStartElement("AMOUNT");
            writer.WriteValue(AMOUNT);
            writer.WriteEndElement();
 
            writer.WriteEndElement();
            writer.WriteEndDocument();
 
            writer.Flush();
            #endregion
 
            return sb.ToString();
        
 
    }
 
Now I can test it by passing an xml file to the parameter on my webservice link and it is responding,but the problem is the system is not able to receive the response of my system when sending the xml file.
Now my question is how to test the incoming xml inorder to see if I can get the incoming xml file.Please help on that because I do not understand what is the problem.Thanks!
Posted 25-Mar-13 23:15pm
El Dev815
Edited 26-Mar-13 0:58am
(no name)35.7K
v3
Comments
Prasad Khandekar at 26-Mar-13 15:03pm
   
Why not print the incoming xml (parameter to your method). You can use HTTPTester chrome plugin to do the actual testing. The plugin will act as the CompanyA program.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 155
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411028.1 | Last Updated 26 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100