user2317678
user2317678

Reputation:

How pass XML file to the method?

I have a method in service that has this signature:

public string submitInvoice(string username, string password, string inXML)

I created XML in my C# code like this:

   protected XmlDocument generateXML()
    {
        XmlDocument xmldoc = new XmlDocument();
        XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
        xmldoc.AppendChild(xmlnode);
        //root element
        XmlElement xmlelem = xmldoc.CreateElement("", "Invoices", "");
        xmldoc.AppendChild(xmlelem);



        //(child of the root)
        XmlElement xmlelem2 = xmldoc.CreateElement("", "InvoiceNumber", "");
        XmlText xmltext = xmldoc.CreateTextNode("222222");
        xmlelem2.AppendChild(xmltext);
        xmldoc.ChildNodes.Item(1).AppendChild(xmlelem2);



        return xmldoc;

    }

in my program I have:

XmlDocument xml = generateXML();

and then call that method:

oResponse = oWscape.submitInvoice(sUserName, sPassword, *); I am not sure what should I send as inXML, it is type string but when I try string it gave me an error. How I can send an XML here?

Upvotes: 0

Views: 2418

Answers (1)

ThatBlairGuy
ThatBlairGuy

Reputation: 2462

You can get the XML as a string via the document element's OuterXml property, as in:

submitInvoice("username", "password", xml.DocumentElement.OuterXml);

Upvotes: 1

Related Questions