M
Matthew Holton
Hello everyone,
I have a couple of questions. Please jump in and provide
your comments and views.
First, does the webservice not behave as a normal
webpage? Here is my reasoning:
I have a webservice with a method that increments
a session variable.
<WebMethod(EnableSession:=True)>Public Function
Increment() as Long
Dim iRet as long
iRet = clng(Session("MyNumber"))
iRet = iRet + 1
Session("MyNumber") = iRet
Return iRet
End Function
I have two clients
VB.Net Application that has a web reference to
this webservice.
Sub Button_Click(Object, Args)
Dim iAnswer as Long
Dim i as Long
Dim WS as MyWebservice.ServiceName
WS= New MyWebservice.ServiceName()
WS.Url
= "http://localhost/myservice/ServiceName.asmx"
For i = 1 to 100
iAnswer = ws.Increment()
debug.write("The answer was:" &
iAnswer.tostring())
'This always returns 1
Next i
End Sub
VB 6.0 Application using XML
Function Test() as Long
Dim iAnswer as Long
On Error GoTo Test_Error
Dim objXMLHeader As XMLDocument
Dim objHTTP As MSXML2.XMLHTTP
Dim strEnvelope As String
Set objXMLHeader = New XMLDocument
Set objHTTP = New MSXML2.XMLHTTP
strEnvelope = "<?xml version='1.0' encoding='utf-
8'?>"
strEnvelope = strEnvelope & "<soap:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
strEnvelope = strEnvelope & " <soap:Body>"
strEnvelope = strEnvelope & " <Increment
xmlns='http://cname.mydomain.com/'>"
strEnvelope = strEnvelope & " </ Increment >"
strEnvelope = strEnvelope & " </soap:Body>"
strEnvelope = strEnvelope & "</soap:Envelope>"
objHTTP.Open "POST", "http://localhost/myservice/s
ervicename.asmx", False
Call objHTTP.setRequestHeader("Content-
Type", "text/xml")
objHTTP.setRequestHeader "SOAPAction", "http://loc
alhost/myservice/servicename.asmx/Increment"
objHTTP.send strEnvelope
'Do While Not objHTTP.readyState = 4
'Sleep 1
'Loop
Dim x As MSXML2.DOMDocument
Set x = New DOMDocument
If x.loadXML(objHTTP.responseText) Then
iAnswer = x.selectSingleNode
("soap:Envelope/soap:Body/IncrementResponse").nodeTypedVal
ue
End If
Test = iAnswer
'Always returns the next number
Exit Function
Test_Error:
End Function
Sub Button_Click()
debug.print test 'Always the next number
End Sub
I would have expected that the vb.net application would
have behave as expected and that the xml solution would
have been a new session as each time a connection was
created. I now expect that I have to tell the webservice
that I am done with it from the vb 6.0 application so
that it could call session.abandon. There goes a
security model. Am I missing something?
The second question is "Should I create a DCOM Component
or Webservice?". I have a need to create a component
that is accessable from vb 6.0 applications, vb.net
applications, and asp.net websites. The component is
required to cache information while instantiated to
reduce redundant calls to the database. Security is
managed internally with this component. All consumers of
this component will be on the LAN but I do not want to
have to manage dll's on each machine or the .Net security
configuration. If the answer is DCOM, where can I get
more information on building them in .Net?
Thanks in advance
I have a couple of questions. Please jump in and provide
your comments and views.
First, does the webservice not behave as a normal
webpage? Here is my reasoning:
I have a webservice with a method that increments
a session variable.
<WebMethod(EnableSession:=True)>Public Function
Increment() as Long
Dim iRet as long
iRet = clng(Session("MyNumber"))
iRet = iRet + 1
Session("MyNumber") = iRet
Return iRet
End Function
I have two clients
VB.Net Application that has a web reference to
this webservice.
Sub Button_Click(Object, Args)
Dim iAnswer as Long
Dim i as Long
Dim WS as MyWebservice.ServiceName
WS= New MyWebservice.ServiceName()
WS.Url
= "http://localhost/myservice/ServiceName.asmx"
For i = 1 to 100
iAnswer = ws.Increment()
debug.write("The answer was:" &
iAnswer.tostring())
'This always returns 1
Next i
End Sub
VB 6.0 Application using XML
Function Test() as Long
Dim iAnswer as Long
On Error GoTo Test_Error
Dim objXMLHeader As XMLDocument
Dim objHTTP As MSXML2.XMLHTTP
Dim strEnvelope As String
Set objXMLHeader = New XMLDocument
Set objHTTP = New MSXML2.XMLHTTP
strEnvelope = "<?xml version='1.0' encoding='utf-
8'?>"
strEnvelope = strEnvelope & "<soap:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
strEnvelope = strEnvelope & " <soap:Body>"
strEnvelope = strEnvelope & " <Increment
xmlns='http://cname.mydomain.com/'>"
strEnvelope = strEnvelope & " </ Increment >"
strEnvelope = strEnvelope & " </soap:Body>"
strEnvelope = strEnvelope & "</soap:Envelope>"
objHTTP.Open "POST", "http://localhost/myservice/s
ervicename.asmx", False
Call objHTTP.setRequestHeader("Content-
Type", "text/xml")
objHTTP.setRequestHeader "SOAPAction", "http://loc
alhost/myservice/servicename.asmx/Increment"
objHTTP.send strEnvelope
'Do While Not objHTTP.readyState = 4
'Sleep 1
'Loop
Dim x As MSXML2.DOMDocument
Set x = New DOMDocument
If x.loadXML(objHTTP.responseText) Then
iAnswer = x.selectSingleNode
("soap:Envelope/soap:Body/IncrementResponse").nodeTypedVal
ue
End If
Test = iAnswer
'Always returns the next number
Exit Function
Test_Error:
End Function
Sub Button_Click()
debug.print test 'Always the next number
End Sub
I would have expected that the vb.net application would
have behave as expected and that the xml solution would
have been a new session as each time a connection was
created. I now expect that I have to tell the webservice
that I am done with it from the vb 6.0 application so
that it could call session.abandon. There goes a
security model. Am I missing something?
The second question is "Should I create a DCOM Component
or Webservice?". I have a need to create a component
that is accessable from vb 6.0 applications, vb.net
applications, and asp.net websites. The component is
required to cache information while instantiated to
reduce redundant calls to the database. Security is
managed internally with this component. All consumers of
this component will be on the LAN but I do not want to
have to manage dll's on each machine or the .Net security
configuration. If the answer is DCOM, where can I get
more information on building them in .Net?
Thanks in advance