This tutorial will show how to accomplish two common tasks using 4S4C,
  1. Using OleView to build the config.xml file
  2. Returning arbitrary XML (or XML Fragments) as string parameters.

1. Building the config.xml file

If you're not familiar with the inner guts of COM, then you may well be wondering what on earth the iid parameter is in the config.xml file, to recap, here's the config.xml as it ships.
	<mapping methodURI='http://simon.fell.com/calc'        progid='Demo_server.calc'     iid='{BC0E4845-B3F3-4080-B914-3F29FF8A06DF}' />
	<mapping methodURI='http://simon.fell.com/strings'     progid='Demo_server.calc'     iid='{2F4178E5-8627-4930-942A-1EFBB3F4F54E}' />
	<mapping methodURI='http://simon.fell.com/structs'     progid='Demo_server.calc'     iid='{63B54535-8599-4f3c-8718-59177D56F928}' />
	<mapping methodURI='http://simon.fell.com/dual'        progid='Demo_server.dualtest' iid='{E4482471-6E9D-429C-B33E-9D48E0010F03}' />
	<mapping methodURI='http://simon.fell.com/addressbook' clsid='{5803B782-DF93-49E4-9105-ED31AB530511}' iid='{91D32B9C-8837-4D08-8F02-945A209E4DB1}' />
	<mapping methodURI='http://simon.fell.com/trickyTypes' progid='Demo_server.calc'     iid='{02A1A326-4489-4b28-A6A9-91F1727672F3}' />
the IID is the Interface ID, and uniquely identifies a COM interface. If you are coding in C++\ATL, then you know that you can find the IID in your projects IDL file. If you only code in VB, you may never even heard of an IID. Fear not !, OleView which ships with many Microsoft tools (including the platform SDK & the NT/2000 resource kits), can show you this information. Here's how If you are developing purely in VB, then typically the VB classes public methods are exposed in an interface called _[ClassName] where [ClassName] is the name of the class, e.g. given a VB class PartsManager, it will have an interface called _PartsManager which exposes all the public methods in the class.

2. Returning non SOAP XML as string parameters

From my time on the SOAP mailing list, it appears that lots of people want to transport arbitrary XML over SOAP. Whilst I think in general that this somewhat misses the point, here's a couple of examples of how you would do this using a component exposed through 4S4C.

We'll create a simple ActiveX DLL VB project, called tutorial, with a single class called someXML
We'll add two public methods that return order data in an XML format, for the first method, we'll just build the XML manually, for the second method we'll persist a recordset to its XML representation. Paste this code into the newly created class
Option Explicit

Public Function GetOrderStatus1() As String
    GetOrderStatus1 = "<order><num>43210</num><orderdate>2000-08-10</orderdate><shipdate>2000-08-12</shipdate></order>"
End Function

Public Function GetOrderStatus2() As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.Fields.Append "num", adInteger
    rs.Fields.Append "orderdate", adDate
    rs.Fields.Append "shipdate", adDate
    rs("num").Value = "43210"
    rs("orderdate").Value = #8/10/2000#
    rs("shipdate").Value = #8/12/2000#
    Dim s As ADODB.Stream
    Set s = New ADODB.Stream
    rs.Save s, adPersistXML
    s.Position = 0
    GetOrderStatus2 = s.ReadText
End Function
Build the project, remembering to add a reference to Microsoft ADO 2.5.

Now we'll add this class to our config.xml, using the instructions above for oleView, find the IID for the default interface on the class, you can find the class in OleView by looking for tutorial.someXML, in my case, the IID turned out to be {765A1C98-FA42-41E5-BDD1-604474D2F1B2}, but I can guarantee that yours will be different. Once you got the IID, open up the 4s4c\http\asp\config.xml file and add the entry
<mapping methodURI='http://simon.fell.com/xml' progid='tutorial.someXML' iid='{765A1C98-FA42-41E5-BDD1-604474D2F1B2}' />
Now you can run the tutorial client, in this case its an IE5 page that uses MSXML at the client, to parse the returned SOAP message. you can open the client, and try it out.

If you get an error from the client, you may need to restart IIS, to clear the cached config.xml.

<<< The Dispatcher Component      >>> Version History