asked on
<?xml version="1.0"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError" />
</QBXML>
void BuildCustomerAddRq(XmlDocument doc, XmlElement parent)
{
try
{
string ConString = "Data Source=192.168.0.40;Initial Catalog=OCITIME;User ID=ocisql;Password=Emagdne1212";
string CmdString = "select employee_name as Name ,'OCI Associates' as [CompanyName],'Mr' as Salutation , LEFT(employee_name, CHARINDEX(' ', employee_name + ' ') - 1) as FirstName, REVERSE(LEFT(REVERSE(employee_name), CHARINDEX(' ', REVERSE(employee_name)) - 1)) AS LastName from EMPLOYEELIST for xml raw('CustomerAdd') , ROOT('CustomerAddRq'), ELEMENTS";
SqlConnection con;
SqlCommand cmd;
XmlReader reader;
XmlDocument xmlDoc;
using (con = new SqlConnection(ConString))
{
cmd = new SqlCommand(CmdString, con);
con.Open();
reader = cmd.ExecuteXmlReader();
while (reader.Read())
{
doc.Load(reader);
}
doc.AppendChild(doc.CreateXmlDeclaration("1.0", null, null));
doc.AppendChild(doc.CreateProcessingInstruction("qbxml", "version=\"13.0\""));
doc.Save("C:\\Employees.xml");
}
}
catch (Exception)
{
throw;
}
}
//This is the shit to create requests and submit to QUICKBOOKS
public ArrayList buildRequest()
{
XmlDocument requestXmlDoc = new XmlDocument();
//Add the prolog processing instructions
requestXmlDoc.AppendChild(requestXmlDoc.CreateXmlDeclaration("1.0", null, null));
requestXmlDoc.AppendChild(requestXmlDoc.CreateProcessingInstruction("qbxml", "version=\"13.0\""));
//Create the outer request envelope tag
XmlElement outer = requestXmlDoc.CreateElement("QBXML");
requestXmlDoc.AppendChild(outer);
//Create the inner request envelope & any needed attributes
XmlElement inner = requestXmlDoc.CreateElement("QBXMLMsgsRq");
outer.AppendChild(inner);
inner.SetAttribute("onError", "stopOnError");
BuildCustomerAddRq(requestXmlDoc, inner);
string strRequestXML = requestXmlDoc.OuterXml;
req.Add(strRequestXML);
requestXmlDoc.Save("C:\\testing123.xml");
return req;
}
<?xml version="1.0"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="1">
<CustomerAdd>
<Name>Fake Name</Name>
<CompanyName>Fake Company</CompanyName>
<Salutation>Mr.</Salutation>
<FirstName>Fake</FirstName>
<MiddleName>P</MiddleName>
<LastName>Name</LastName>
<JobTitle>Systems Engineer</JobTitle>
<BillAddress>
<Addr1>1234 Fake Address</Addr1>
</BillAddress>
<ShipToAddress>
<Name>Fake Name</Name>
</ShipToAddress>
<Phone>123-126-123</Phone>
<AltPhone>123-123-123</AltPhone>
<Email>gashlin@gmail.com</Email>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>
<CustomerAddRq>
<CustomerAdd>
<Name>Fake Name</Name>
<CompanyName>Fake Company</CompanyName>
<Salutation>Mr</Salutation>
<FirstName>Fake</FirstName>
<LastName>Name</LastName>
</CustomerAdd>
</CustomerAddRq>
C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).
TRUSTED BY
ASKER
i was able to get it kind of right using this code -
Open in new window
however ...
It gives me this
Open in new window
I need this -
Open in new window
See the QBXMLMsgRq is end itself early. needs to be in the correct location.