Using ASP with VBScript

One means of setting up the XML files for communicating with the 3DPartStream.NET is to use ASP files and COM objects.  The following discussion will include elements of a standard ASP file that can be used, refer to the code in viewrequest.asp for the full solution.

All requests that are made to the 3DPartStream.NET start from an empty SOAP request template file.

 

<SOAP-ENV:Envelope

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

    <SOAP-ENV:Header>

        <interfacename>Name of Interface</interfacename>

    </SOAP-ENV:Header>

    <SOAP-ENV:Body>

        <interfaceparameters>

        </interfaceparameters>

    </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

 

The basic ASP file starts by creating a Request COM object from a Microsoft.XMLDOM class. After the request is constructed, the XML interpretation properties are set and the empty SOAP request template is loaded.

 

<%@ Language=VBScript %>

<%

 

set SOAPRequestTemplate = Server.MapPath("SOAPRequestTemplate.xml")

set xmlRequest = Server.CreateObject("Microsoft.XMLDOM")

 

xmlRequest.async = false

xmlRequest.validateOnParse = false

 

xmlRequest.load(SOAPRequestTemplate)

 

Once the template has been loaded into the XMLDOM object, the script will then set the desired interface and its parameters.  In the example, the model name is provided by a separate form.

 

set elemlist = xmlRequest.getElementsByTagName("InterfaceName")

for i=0 to elemlist.length-1

    set iName = elemlist.item(i)

next

 

set elemlist = xmlRequest.getElementsByTagName("InterfaceParameters")

for i=0 to elemlist.length-1

    set iParam = elemlist.item(i)

next

 

modelName = Request("modelName")

interfaceName = Request("interfaceName")

 

if (interfaceName = "View Model") then

    iName.text = "SWGetModelView3D"

    set modelElement = xmlRequest.createElement("model")

    modelElement.text = modelName

    iParam.appendChild modelElement

end if

 

Now that the XML template has been filled, a connection to the 3DPartStream.NET can be made using a Microsoft.XMLHTTP COM object.

 

set targetSOAPServer = "http://" + targetSOAPmachine + "/SWService/3DPublishingService.asp"

 

set req = Server.CreateObject("Microsoft.XMLHTTP")

set reqLogin = Server.CreateObject("Microsoft.XMLHTTP")

 

'open HTTP request

 

call req.open("POST", targetSOAPServer, false)

call req.setRequestHeader("Content-Type", "text/xml-soap")

 

call req.send(xmlRequest.xml)

 

3DPartStream.NET will then return a similar XML template containing either success or failure information.  In the case of success, there will be either a link to a viewable file or an XML file to be processed for writing.

 

if (req.status = 200) then

    set responseDOM = req.responseXML

    set faultNode = responseDOM.selectSingleNode("//faultstring")

 

    if (faultNode is nothing) then

        set returnNode = responseDOM.selectSingleNode("//returnVal")

 

        if (returnNode is nothing) then

            set successNode = responseDOM.selectSingleNode("//success")

 

            Response.Write(successNode.text + "<BR>")

        else

         end if

    else

        Response.Write("<BR>Error Description: " + faultNode.text)

        set faultCode = responseDOM.selectSingleNode("//faultcode")

        Response.Write("<BR>Error Number: " + faultCode.text)

    end if

else

    Response.Write("HTTP Request Failed")

end if