Classic ASP SmarterTrack Webservice Interface

In my first SmarterTrack article I discussed the building a Login Provider web service, In this article I am going to show you a simple implementation of of using Classic ASP to communicate with the SmarterTrack web services to enhance your current app. by proving a few simple methods for creating a ticket from a classic ASP page.
A perfect example would be a classic ASP shopping cart that displays past orders to a customer and you want to provide a quick way for your customers to create a customer service ticket without entering the customer service portal.
The example here was used with version 5.0.3813 of SmarterTrack installed locally on my machine. And you will also need the Microsoft 'SOAP Toolkit 3.0', it can be downloaded from Microsoft @ http://www.microsoft.com/downloads/details.aspx?familyid=c943c0dd-ceec-4088-9753-86f052ec8450&displaylang=en.
This is a simple method and does not provide any error handling or business logic, Ill leave that up to you to implement. this is only meant to show you the proper way to call the SmarterTrack web service's from classic ASP.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | <% Class SmarterTrack_svcTicket '##################################################################################################### '################################################################# 'VERY IMPORTANT: When attempting to get this class to work we were getting the following error: '################################################################# 'WSDLReader error '80020009' 'WSDLReader:Loading of the WSDL file failed HRESULT=0x80040154: Class not registered - 'Client:An unanticipated error occurred during the processing of this request. HRESULT=0x80040154: Class not registered 'The error occurred the following line in "Class_Initialize": 'oSOAP.mssoapinit WebserviceURL & "svcTickets.asmx?WSDL", "svcTickets" 'To get this SOAP functionality to work, make sure that the following is installed on the machine (this fixed our error above): '1) SOAP Toolkit 3.0 (http://www.microsoft.com/downloads/en/details.aspx?FamilyId=C943C0DD-CEEC-4088-9753-86F052EC8450&displaylang=en) '2) MSXML 4.0 Service Pack 2 (Microsoft XML Core Services) ' - http://www.microsoft.com/downloads/en/details.aspx?familyid=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&displaylang=en ' - install msxml.msi 'Private Declarations Private oSOAP Private svcTicketsWDSL Private svcTicketsNamespace Private svcResponse 'Public Declarations Public AgentUserName Public AgentPassword Public WebserviceURL Public WebServiceTimeout Public TicketNumber Public Result Public ResultCode Public RequestResult 'Create & Destroy Methods Private Sub Class_Initialize WebserviceURL = "http://localhost:9996/services/" 'Default Value (DEV Address) AgentUserName = "admin" AgentPassword = "admin" WebServiceTimeout = 10000 '10 seconds Set oSOAP = Server.CreateObject("MSSOAP.SoapClient30") oSOAP.ClientProperty("ServerHTTPRequest") = True oSOAP.mssoapinit WebserviceURL & "svcTickets.asmx?WSDL", "svcTickets" oSoap.ConnectorProperty("Timeout") = WebServiceTimeout End Sub Private Sub Class_Terminate Set oSOAP = Nothing End Sub 'Subroutines Public Function CreateTicket(byVal intDeptID,byVal UserEmailAddress, byVal Subject, byVal MessageBody, byVal SendAutoRespond) Response.Write "<hr>CreateTicket()<br>" Set svcResponse = oSOAP.CreateTicket(AgentUserName, AgentPassword, intDeptID, UserEmailAddress, Subject, MessageBody , false, SendAutoRespond) Call ProcessResponse() TicketNumber = RequestResult End Function Public Function GetTicketURL() 'Response.Write "<hr>AddTicketNote('" & TicketNumber & "')<br>" 'For Debugging Set svcResponse = oSOAP.GetTicketURL(AgentUserName, AgentPassword, TicketNumber) Call ProcessResponse() GetTicketURl = RequestResult End Function Public Function ProcessResponse() For Each Node In svcResponse 'Response.Write Node.tagName & " : " & Node.xml & "<br>" Select Case Node.tagName Case "RequestResult" 'Ticket Number RequestResult = Node.Text Case "Message" Message = Node.Text Case "Result" Result = Node.Text Case "ResultCode" ResultCode = Node.Text Case Else 'Response.write "CreateTicket : Unknown Response Node = " & Node.tagName & "<br>" End Select Next End Function '##################################################################################################### End Class 'Sample Usuage Dim Ticket Set Ticket = New SmarterTrack_svcTicket Ticket.CreateTicket 1,"customer@summit-pro.com", "Missing Items On Order", "Customer reported they did not receive there widget", True Response.Write ( Ticket.GetTicketURL() ) Set Ticket = Nothing %> |
December 10th, 2010 - 01:26
Brilliant article, thank you. I copied and pasted the code, changed the login details and the server URL, worked once, thought my prayers were answered! Tried it a second time (and a million more) and now all I get is:
WSDLReader:XML Parser failed at linenumber 0, lineposition 0,
reason is: The server returned an invalid or unrecognized response
HRESULT=0×1: Incorrect function.
- WSDLReader:Loading of the WSDL file failed HRESULT=0×80070057: The
parameter is incorrect.
- Client:One of the parameters supplied is invalid. HRESULT=0×80070057:
The parameter is incorrect.
Downloaded the latest SOAP toolkit, and the latest smartertrack too
December 30th, 2010 - 09:16
Hmmm, interesting issue your having Mark. I do remember having a similar issue during the initial development of the class. and i think it had something to do with the IIS7 application pool. but for the life of me cant remember the exact cause.
try changing the settings in your application pool to see if it makes any difference. the site i have this code running on is set like the following.
Enable 32-Bit applications (True)
Managed Pipeline Mode (Integrated)
.Net Framework Version (No Managed Code)
Let me know if that fixes the problem, If not I will try setting up a new site and see if I cant recreate the problem.