Directory Services

Transmitting and Receiving SOAP-DSML Messages

DSML Services for Windows implements SOAP via HTTP binding.

The following code example shows how to configure a Web page that employs server-side scripting to enable a client to transmit and receive SOAP-DSML messages. This Web-page code is common to each of the LDAP-operations topics that follow. Therefore, only the Web-page code will be discussed here, and the SOAP-DSML code will be discussed separately in topics that follow.

In the following example, the SOAP envelope that contains the DSML payload is sent from the server to the client, and from the client to the server over HTTP. This process is accomplished by creating a Web page that imports the SOAP envelope and its payload into a form, displays it, and then transmits it to the server by using Visual Basic Scripting Edition (VBScript) to perform an HTML POST operation. The following code example shows how this process works.

sub postit(theform)
	set xmlhttp = CreateObject("Msxml2.XMLHTTP") "POST", "http://localhost/dsmlsoap/adssoap.dsmlx", false
	xmlhttp.setRequestHeader "SOAPAction", """#batchRequest"""
	xmlhttp.send theform.requestEl.value
	theform.responseEl.value = xmlhttp.responsetext
	set xmlDom = xmlhttp.responseXml "c:\result.xml"
	theform.ResponseXml.Navigate "c:\t.xml"
end sub

sub LoadDoc()
	set dom = CreateObject("Microsoft.XMLDOM")
	dom.async = False
	path = Mid(Location.Search,2)
	dom.Load path
	myform.requestEl.value = dom.Xml
end sub


<BODY OnLoad="LoadDoc">

<FORM name="myform" METHOD=POST ACTION="http://localhost/dsmlsoap/adssoap.dsmlx" >

<img border="0" src="sample.JPG" width="89" height="92"> 
<img border="0" src="dsmlsoap.jpg" width="435" height="47">
   <p><font face="Verdana" size="2">DSML 2.0 request: </font></p>
<TEXTAREA fontsize="large" rows="10" cols=110 name="requestEl">

<INPUT TYPE="button" Value="Send Request" OnClick="postit(myform)">

<font face="Verdana" size="2">The DSML 2.0 response: </font>

<TEXTAREA rows="20" cols=110 name="responseEl">



This Web-page code creates a form named myform and, through the VBScript subroutine LoadDoc(), creates a DOMDocument object and, using this object, loads a SOAP message that contains the DSML payload. The Mid function is used in conjunction with the Location.Search method to get the path to the file Add.xml, which contains the SOAP and DSML XML elements. This path is then used to load and display the XML payload and to include the XML code in the HTTP request. A real-life application would probably collect data from the user and then create the SOAP and DSML elements using this information.

The form also contains a Send Request button that, when clicked, calls the Visual Basic subroutine postit, and which passes the argument myform. The postit subroutine then posts the HTTP request to the server.

The postit subroutine creates an IXMLHTTPRequest object named xmlhttp. The Open method is used to configure the necessary POST data. In this example, the data includes the URL to Adssoap.dll and the synchronous operation setting. Next, the request header data is configured using the setRequestHeader method. Then the Send method is used to send the request to the server.