sujalaroy
Apr 29th, 2003, 05:24 AM
We have a requirement in our project wherein we need to get some stock information & display it to the user. The application is pure ASP & VB based. We are wondering whether we can use a web-service to do this job. Want to know if its possible in someway to use Web-Service in an ASP application (thru some COM wrapper). Creating the web-service wont be a problem as .Net Framework will be available to us.
Anybody any thoughts??
Thanks in advance,
Sujala
TheExtreme
Apr 29th, 2003, 09:11 AM
You have serveral options including:
Write a VB.NET Assembly and make it COM Compliant
Write VB6 DLL to access web Services through Winsock,etc
My question would be why are you wanting to use COM in the first place.
sujalaroy
Apr 30th, 2003, 11:20 AM
Thanks for ur reply.. but what are the other options (other than COM) since we have to plug it in an ASP application. yes, its stupid to use web-services but not develop the application in .Net. but thats how have things gone so far. initially there was no requirement of showing weather information on the site, so the client dint want to use .Net, but now they are "considering" installing .Net framework in the production m/c in order to make the web-service work :-).. thats how clients (& our marketing guyz ) are u know...
can u throw some light pls on how make a web-service developed either thru C# or VB.Net COM compliant??
thnks again,
sujala
TheExtreme
Apr 30th, 2003, 11:39 AM
the idea behind a web-service is that it can be platform/language independant. Write your web sevice to send and recieve XML. XML is fully supported by ASP, VB6, ASP.NET, VB.NET, Linux, Unix, etc, etc.
Cander
Apr 30th, 2003, 12:13 PM
right. a .NET web service sends data via XML and SOAP. There are implementtions of this for virtually everything. you dont NEED .NET to access a web service. J2EE for example hs web service accessing and writting stuff. The SOAP toolkit from Microsoft can be used in VB6 and other ActiveX compliant language on Windows. There are tons more. check out xmethods.com and you can see plenty of public web services written on a variety of platforms.
Lethal
Apr 30th, 2003, 12:20 PM
I wrote some adhoc webservices a while back using ASP and XML (MSXML COM Objects). If you would like to see an example, let me know.
sujalaroy
Apr 30th, 2003, 12:33 PM
yes, Lethal.. a ready eg. will definitely help. can u copy-paste/upload ur prgrams here?
thnxalot,
sujala
Lethal
Apr 30th, 2003, 12:37 PM
Here is one example:
<%
Option Explicit
Response.CacheControl = "no-cache"
Response.ContentType = "text/xml"
On Error Resume Next
Const adVarChar = 200
Const adChar = 129
Const adInteger = 3
Const adDate = 7
Const adParamInput = 1
Const adCmdStoredProc = 4
Dim objConnection
Dim objCommand
Dim strUserID
Dim strPassword
Dim strConnectionString
Dim strXMLRequest
Dim xmlDoc
Dim strDivisionNbr
Dim strAccountNbr
Dim strUserName
Dim strDomainName
Dim strMachineName
Dim strRequest
Dim strResponseCode
Dim strOperatorID
Dim strRegions
Dim strPurgeDate
Dim strStatus
Dim strAssociateId
Dim xmlResponseDoc
Dim xmlErrorDoc
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Set xmlResponseDoc = CreateObject("Microsoft.XMLDOM")
'Convert the Byte Code to Ascii Text
strXMLRequest = BytesToText(Request.BinaryRead(Request.TotalBytes))
xmlDoc.async = False
xmlDoc.LoadXML strXMLRequest
GenerateErrorResponse 'Check for any errors
'Retrieve the various paramaters that will be written to the database
strDivisionNbr = xmlDoc.documentElement.selectsinglenode("DIVISION_NBR").text
strAccountNbr = xmlDoc.documentElement.selectsinglenode("ACCOUNT_NBR").text
strUserName = xmlDoc.documentElement.selectsinglenode("USER_RACF").text
strDomainName = xmlDoc.documentElement.selectsinglenode("DOMAIN_NAME").text
strMachineName = xmlDoc.documentElement.selectsinglenode("MACHINE_NAME").text
strRequest = xmlDoc.documentElement.selectsinglenode("REQUEST").text
strResponseCode = xmlDoc.documentElement.selectsinglenode("RESPONSE_CODE").text
strOperatorID = xmlDoc.documentElement.selectsinglenode("OPERATOR_ID").text
strRegions = xmlDoc.documentElement.selectsinglenode("REGIONS").text
strPurgeDate = xmlDoc.documentElement.selectsinglenode("PURGE_DATE").text
strStatus = xmlDoc.documentElement.selectsinglenode("STATUS").text
strAssociateId = xmlDoc.documentElement.selectsinglenode("ASSOCIATE_ID").text
GenerateErrorResponse 'Check for any errors
'Establish connection to the SQL Database
strUserID = "***"
strPassword = "***"
strConnectionString = "Provider=SQLOLEDB; Data Source=***; Initial Catalog=***"
objConnection.Open strConnectionString, strUserID, strPassword
'Create and populate the paramaters collection
With objCommand
.Parameters.Append .CreateParameter("AssociateId", adVarChar, adParamInput, 8, strAssociateId )
.Parameters.Append .CreateParameter("Operator", adChar, adParamInput, 3, strOperatorID)
.Parameters.Append .CreateParameter("Division", adInteger, adParamInput, , CInt(strDivisionNbr))
.Parameters.Append .CreateParameter("Account", adVarChar, adParamInput, 32, strAccountNbr)
.Parameters.Append .CreateParameter("Domain", adVarChar, adParamInput, 30, strDomainName)
.Parameters.Append .CreateParameter("MachineName", adVarChar, adParamInput, 30, strMachineName)
.Parameters.Append .CreateParameter("Region", adChar, adParamInput, 1, strRegions)
.Parameters.Append .CreateParameter("Request", adChar, adParamInput, 2, strRequest)
.Parameters.Append .CreateParameter("Response", adChar, adParamInput, 2, strResponseCode)
.Parameters.Append .CreateParameter("Date", adDate, adParamInput, , CDate(strPurgeDate))
.Parameters.Append .CreateParameter("Status", adVarChar, adParamInput, 100, strStatus)
.Parameters.Append .CreateParameter("UserName", adVarChar, adParamInput, 8, strUserName)
'Initialize and execute the stored procedure
.ActiveConnection = objConnection
.CommandText = "p_Add_MPS"
.CommandType = adCmdStoredProc
.Execute
End With
GenerateErrorResponse 'Check for any errors
'Build Xml Response Document
xmlResponseDoc.appendChild xmlResponseDoc.createElement("UPDATE_MPS_STATUS_SCREEN_RESP")
xmlResponseDoc.documentElement.appendChild xmlResponseDoc.createElement("SUCCESS")
Response.Write xmlResponseDoc.xml 'Write Out the Response Xml
Response.End
'This routine grabs the specified value from the node, and if it is empty, return a null string
Function SetValue(xmlRoot, strTagName)
Dim xmlNodeList
Set xmlNodeList = xmlRoot.getElementsByTagName(strTagName)
If xmlNodeList.length > 0 Then
SetValue = xmlRoot.selectSingleNode("//" & strTagName).Text
Else
SetValue = ""
End If
Set xmlNodeList = Nothing
End Function
'Read the byte stream in from the request object, then convert it to its ascii form
Function BytesToText(strBytes)
Dim lngLength
Dim lngIndex
Dim lngAsciiCode
Dim strAsciiText
lngLength = LenB(strBytes)
For lngIndex = 1 To lngLength
lngAsciiCode = AscB(MidB(strBytes, lngIndex, 1))
strAsciiText = strAsciiText & Chr(lngAsciiCode)
Next
BytesToText = strAsciiText
End Function
'Generate Xml Error Response if an error occurs
Sub GenerateErrorResponse()
If Not Err.number = 0 then
Set xmlErrorDoc = CreateObject("Microsoft.XMLDOM")
xmlErrorDoc.appendChild xmlErrorDoc.createElement("UPDATE_MPS_STATUS_SCREEN_RESP")
xmlErrorDoc.documentElement.appendChild( xmlErrorDoc.createElement("ERROR")).Text = Err.description
Response.Write xmlErrorDoc.xml
Response.End
End if
End Sub
%>
WiKiDJeFF
May 14th, 2003, 04:15 PM
w3schools.com has a great web service tutorial and some good examples too.