|
Step 2: Build the Server Calculator Component
Next, create the server component that performs the calculator operations. Open Visual Basic 6 and create a new ActiveX DLL project. Follow the instructions for the CalcServ class in SOAP Toolkit's "Using a Low Level API for SOAP Messages" sample application, but change the project name to SOAPCalc. If you do not have Visual Basic, you can download the compiled CalcServ component installer application (see References). The installer copies and registers all the necessary files. Listing 1 contains the complete VB source.
The sample application code reads the incoming request with a SOAP reader object. It then checks the request for a node called <Add>, <Subtract>, <Multiply> or <Divide> and two child nodes <A> and <B> inside the body of the SOAP Envelope. If it finds these elements, it processes the request and returns a SOAP message using the serializer and the ASP Response object.
Flash's XML parser cannot process XML tag namespaces, so you need to simplify the structure of the SOAP messages sent by the component to produce predictable tags. Here's a standard SOAP body containing the :
<SOAPSDK1:AddResponse xmlns:SOAPSDK1="uri:Calc">
<SOAPSDK1:Answer>12</SOAPSDK1:Answer>
</SOAPSDK1:Response>
Don't use the standard SOAP body. Use this simpler Flash-compatible syntax instead. The simpler version contains the same data, but without the SOAPSDK namespace and tag prefixes.
<AddResponse>
<Answer>12</Answer>
</AddResponse>
To make these changes, first remove the constant declaration from the top of the module code:
Const CALC_NS = "uri:Calc"
Next, alter the SOAP Serializer response sequence so it does not specify a namespace for the elements it creates by changing this block:
...
Serializer.startBody
Serializer.startElement MethodName & "Response", CALC_NS
Serializer.startElement "Answer", CALC_NS
...
to this:
...
Serializer.startBody
Serializer.startElement MethodName & "Response"
Serializer.startElement "Answer"
...
Build the DLL and register it on the IIS server that contains your ASP script. To register the DLL, run the regsvr32.exe file from a command prompt or from the Run dialog with a command argument containing the path and filename where you placed the DLL. You do not have to register the DLL if you are running IIS on the same machine where you build the DLL.
|
 |
TALK
BACK |
|
Did you know that Flash 5 was capable of making SOAP calls to server-side code? Using Flash 5's XML capabilities, you can build highly interactive thin-client applications? Let us know what you think of the techniques in this article? Join the discussions at web.server.general and let us know.
|
|
|
|
|
|
|