PSEUDO WEB SERVICES CALLING OTHER SERVICES

B

brian.ackermann

Hello All,

I have a project where I am being asked to expose some functionality
to a customer via a web-service-like interface. This service will be
written in Classic ASP, and will take a number of parameters, process
some logic,and then return some information to the consumer. I've now
built a number of these services (Following something of a RESTful
approach), and the next one I need to build happens to require some
information which is already provided by another service.

The problem is that this doesn't appear to work, and I can't for the
life of me figure out why. Here's a description.

Service A adds some specific information to the system.
Service B adds some general information to the system.

So, when A is called, B is also executed.

Except that this doesn't happen. When B is called directly, it fires
off instantly, does its stuff, and returns its data block. But when A
is called, all is well until I get the point where I 'call' B via
MSXML2.ServerXMLHTTP Send(). At this point, Service A just hangs
indefinitely.

It appears to be some kind of threading issue, like B is waiting to
execute until A is finished running, but A won't finish until B
returns. At least thats how it looks to me, I'm sure the real answer
could be something completely different.

Can this even be done in Classic ASP ? I can't think of any reason
why this general pattern shouldn't be used, but after spending the
better part of a week trying out dozens of failed solutions, I'm
beginning to have doubts!

Thanks for any insight you are able to shed on this situation.

Brian
 
B

brian.ackermann

Could you post stripped down versions the code for
"Service A" and "Service B" that isolate your problem?

Well, at present, Service B is simply an asp page that returns raw XML
text, though it 'USED' to be a 'real service'. But the raw xml output
exhibits the exact same behavior, so I think the content of page B is
irrelevant. Additionally, if I point Service A to a version of
Service B running on a different server, then both Service A and
Service B work as expected. The problem is not, I think, an issue
with the design of the services, but with a limitation of ASP itself
(Though I'm willing to be wrong on that point)

Service A is just an asp page that takes in a parameter and builds
some xml. But it calls a function which fires off the call to Service
B. The line, httpReq.Send, will error out with a timeout error at
the fourth number set in the httpReq.setTimeouts ... in this case
80000ms.

The function looks like this:


Function getNewSessionDataFromWebService()
Dim webServiceUrl, httpReq, node, myXmlDoc

On Error Resume Next

webServiceUrl = "http://sandbox/services/rtSessionAdd.asp?
authkey={75DA987E-8811-40BA-B284-E8B54EE60565}"

Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")

' resolve, connect, send, receive - in milliseconds
httpReq.setTimeouts 1000, 60000, 10000, 80000

httpReq.Open "GET", webServiceUrl,false
response.write "100 - " & err.number & " - " &err.description &
"<br>" & vbcrlf
httpReq.Send

response.write "101 - " & err.number & " - " &err.description &
"<br>" & vbcrlf
Set myXmlDoc =Server.CreateObject("MSXML.DOMDocument")
myXmlDoc.load(httpReq.responseBody)

Set httpReq = Nothing

Set node = myXmlDoc.documentElement.selectSingleNode("Session/ID")

If Not node Is Nothing Then
getNewSessionDataFromWebService = node.text
Else
getNewSessionDataFromWebService = ""
End If

On Error Goto 0
End Function
 
A

Anthony Jones

brian.ackermann said:
Hello All,

I have a project where I am being asked to expose some functionality
to a customer via a web-service-like interface. This service will be
written in Classic ASP, and will take a number of parameters, process
some logic,and then return some information to the consumer. I've now
built a number of these services (Following something of a RESTful
approach), and the next one I need to build happens to require some
information which is already provided by another service.

The problem is that this doesn't appear to work, and I can't for the
life of me figure out why. Here's a description.

Service A adds some specific information to the system.
Service B adds some general information to the system.

So, when A is called, B is also executed.

Except that this doesn't happen. When B is called directly, it fires
off instantly, does its stuff, and returns its data block. But when A
is called, all is well until I get the point where I 'call' B via
MSXML2.ServerXMLHTTP Send(). At this point, Service A just hangs
indefinitely.

It appears to be some kind of threading issue, like B is waiting to
execute until A is finished running, but A won't finish until B
returns. At least thats how it looks to me, I'm sure the real answer
could be something completely different.

Can this even be done in Classic ASP ? I can't think of any reason
why this general pattern shouldn't be used, but after spending the
better part of a week trying out dozens of failed solutions, I'm
beginning to have doubts!

Thanks for any insight you are able to shed on this situation.
Most likely you have ASP Debugging turned on. This limits ASP to one
thread. Hence your analysis is essentially correct the second request is
queued waiting for the first to complete but since the first is waiting for
the second to return you have a deadlock.

Turning off debugging will give ASP 25 threads per process by default.
However if your customer(s) hit pages like this heavily its possible to have
these deadlocks occur in your production environment.

A better approach is to create two ASP include files each containing a Class
whose job it is to create the XML for Service A and B.

Now create an accessor page for service B which includes the service B class
page. This page retrieves an XML DOM from the service B class and dumps it
to the response. Be sure to set ContentType and CharSet correctly:-

Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
oXMLDOM.save Response

Create an accessor page for service A which includes both the service A and
the service B class pages. Use the service B class to create your base XML,
pass the base XML to service class A to specialise then send the resulting
DOM as before.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top