Introduction
Below you will find an example of an application that allows you to create sales invoices in Yuki by using Classic ASP via the ProcessSalesInvoices(sessionID, administrationId, xmlDoc) method.
Example
<%
Dim objXmlHttp
Dim objXmlHttp2
Dim strSessionId
Dim strXml
Dim strAccessKey
Dim strAdministrationId
Dim strWebserviceUrl
Dim strSalesXml
strAccessKey = "REPLACE WTH WEBSERVICEACCESSKEY"
strAdministrationId = "REPLACE WITH ADMINISTRATIONID"
strWebserviceUrl = "https://api.yukiworks.nl/ws/Sales.asmx"
' Build SOAP XML message for WebServiceMethod "http://www.theyukicompany.com/Authenticate".
strXml = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
"<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" & _
"<soap12:Body>" & _
"<Authenticate xmlns=""http://www.theyukicompany.com/"">" & _
"<accessKey>" & strAccessKey & "</accessKey>" & _
"</Authenticate>" & _
"</soap12:Body>" & _
"</soap12:Envelope>"
' Create ServerXMLHTTP object.
Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.open "POST", strWebserviceUrl, False
objXmlHttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
objXmlHttp.setRequestHeader "SOAPAction", "http://www.theyukicompany.com/Authenticate"
objXmlHttp.setRequestHeader "Content-Length", Len(strXml)
' Send SOAP message.
objXmlHttp.send strXml
' Print out the request status.
Response.Write "WebServiceMethod ""Authenticate"" request status: <b>" & objXmlHttp.status & " " & objXmlHttp.statusText & "</b><br /><br />"
' Print out the SOAP XML response.
Response.Write "<div style=""border: solid 1px black;"">" & Server.HTMLEncode(objXmlHttp.responseText) & "</div><br /><br />"
' Parse sessionKey from SOAP XML response with ActiveXObject. If the ActiveXObject "MSXML2.DomDocument.X.X" cannot be found try to find
' another version on MSDN.
Set objXML = Server.CreateObject("MSXML2.DomDocument.3.0")
objXML.loadXML(objXmlHttp.responseText)
strSessionId = objXML.selectNodes("/").item(0).text
Set objXML = Nothing
Set objXmlHttp = Nothing
strSalesXml = "<SalesInvoices xmlns=""urn:xmlns:http://www.theyukicompany.com:salesinvoices""" & _
" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">" & _
" <SalesInvoice>" & _
" <Reference>XX-1234</Reference>" & _
" <Subject>Testfactuur - 1</Subject>" & _
" <PaymentMethod>ElectronicTransfer</PaymentMethod>" & _
" <Process>true</Process>" & _
" <EmailToCustomer>false</EmailToCustomer>" & _
" <Layout />" & _
" <Date>2012-06-22</Date>" & _
" <DueDate>2012-07-22</DueDate>" & _
" <PriceList />" & _
" <Currency />" & _
" <Remarks />" & _
" <Contact>" & _
" <ContactCode>1122</ContactCode>" & _
" <FullName>Apple Sales International</FullName>" & _
" <FirstName />" & _
" <MiddleName />" & _
" <LastName />" & _
" <Gender>Male</Gender>" & _
" <Country Code>NL</CountryCode>" & _
" <City>Rotterdam</City>" & _
" <Zipcode>1234 AA</Zipcode>" & _
" <AddressLine_1>Bergweg 25</AddressLine_1>" & _
" <AddressLine_2 />" & _
" <EmailAddress>[email protected]</EmailAddress>" & _
" <Website />" & _
" <CoCNumber />" & _
" <VATNumber />" & _
" <ContactType>Person</ContactType>" & _
" </Contact>" & _
" <InvoiceLines>" & _
" <InvoiceLine>" & _
" <Description>Regel 1</Description>" & _
" <ProductQuantity>2</ProductQuantity>" & _
" <Product>" & _
" <Description>Product 1</Description>" & _
" <Reference>TP-1122</Reference>" & _
" <Category xsi:nil=""true"" />" & _
" <SalesPrice>14.88</SalesPrice>" & _
" <VATPercentage>6.00</VATPercentage>" & _
" <VATIncluded>true</VATIncluded>" & _
" <VATType>2</VATType>" & _
" <GLAccountCode></GLAccountCode>" & _
" <Remarks />" & _
" </Product>" & _
" </InvoiceLine>" & _
" </InvoiceLines>" & _
" </SalesInvoice>" & _
"</SalesInvoices>"
' Build SOAP XML message for WebServiceMethod "http://www.theyukicompany.com/ProcessSalesInvoices".
strXml = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
"<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" & _
"<soap12:Body>" & _
"<ProcessSalesInvoices xmlns=""http://www.theyukicompany.com/"">" & _
"<sessionId>" & strSessionId & "</sessionId>" & _
"<administrationId>" & strAdministrationId & "</administrationId>" & _
"<xmlDoc>" & strSalesXml & "</xmlDoc>" & _
"</ProcessSalesInvoices>" & _
"</soap12:Body>" & _
"</soap12:Envelope>"
' Create ServerXMLHTTP object.
Set objXmlHttp2 = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp2.open "POST", strWebserviceUrl, False
objXmlHttp2.setRequestHeader "SOAPAction", "http://www.theyukicompany.com/ProcessSalesInvoices"
objXmlHttp2.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
objXmlHttp2.setRequestHeader "Content-Length", Len(strXml)
' Send SOAP message.
objXmlHttp2.send strXml
' Print out the request status.
Response.Write "WebServiceMethod ""ProcessSalesInvoices"" request status: <b>" & objXmlHttp2.status & " " & objXmlHttp2.statusText & "</b><br /><br />"
' Print out the SOAP XML response.
Response.Write "<div style=""border: solid 1px black;"">" & Server.HTMLEncode(objXmlHttp2.responseText) & "</div>"
Set objXmlHttp2 = Nothing
%>
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article