VB6 XML to webservice

leechie

Newcomer
Joined
Aug 26, 2003
Messages
1
Hello All , I have developed a webservice and busy developing a VB6 application to call the webservice's functions. I have

succesfully managed to call all the functions from VB6 sending values to the service and parsing the dataset / XML results into a recordset.

using the DOMDocument. I am having difficulty's perfroming the final batch function the requires a dataset to be submitted. I

have submitted all the necessary code below. If any one could help / advise / direct me would be a god-send. ;-) thanks in

advance Leechie

==============================================

'here is the XML file that is required for the batch function

<?xml version="1.0" ?>
<NewDataSet xmlns="http://tempuri.org/SEND_SM_BATCH.xsd">
<SEND_SM_BATCH>
<LOGIN>leejay</LOGIN>
<PASSWORD>me</PASSWORD>
<MOBILE>27824654567</MOBILE>
<MESSAGE>This is test message 1</MESSAGE>
</SEND_SM_BATCH>
<SEND_SM_BATCH>
<LOGIN>user</LOGIN>
<PASSWORD>me</PASSWORD>
<MOBILE>27824654567</MOBILE>
<MESSAGE>This is test message 2</MESSAGE>
</SEND_SM_BATCH>
<SEND_SM_BATCH>
<LOGIN>user</LOGIN>
<PASSWORD>me</PASSWORD>
<MOBILE>27824654567</MOBILE>
<MESSAGE>This is test message 3</MESSAGE>
</SEND_SM_BATCH>
<SEND_SM_BATCH>
<LOGIN>user</LOGIN>
<PASSWORD>me</PASSWORD>
<MOBILE>27824654567</MOBILE>
<MESSAGE>This is test message 4</MESSAGE>
</SEND_SM_BATCH>
<SEND_SM_BATCH>
<LOGIN>user</LOGIN>
<PASSWORD>me</PASSWORD>
<MOBILE>27824654567</MOBILE>
<MESSAGE>This is test message 5</MESSAGE>
</SEND_SM_BATCH>
</NewDataSet>

==============================================

Here is the xsd file for the above xml file

<?xml version="1.0" standalone="yes" ?>
<xs:schema id="SEND_SM_BATCH" targetNamespace="http://www.tempuri.org/SEND_SM_BATCH.xsd"

xmlns:mstns="http://www.tempuri.org/SEND_SM_BATCH.xsd" xmlns="http://www.tempuri.org/SEND_SM_BATCH.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"

attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="dsSEND_SM_BATCH" msdata:IsDataSet="true" msdata:Locale="en-ZA">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="SEND_SM_BATCH">
<xs:complexType>
<xs:sequence>
<xs:element name="STATUS" msdata:ReadOnly="true" type="xs:string"

minOccurs="0" />
<xs:element name="MESSAGEID" msdata:ReadOnly="true" type="xs:double"

minOccurs="0" />
<xs:element name="CREDITS" msdata:ReadOnly="true" type="xs:double"

minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
==============================================

This is how I am connecting to the webservice through VB6

'create the SOAP XML object to consume the webservice
Set XMLCLASS = New MSSOAPLib30.SoapClient30
'connect to the webservice
XMLCLASS.MSSoapInit2 XML_WSDLFile, XML_WSMLFile, XML_ServiceName, XML_Port, XML_NameSpace
Exit Sub

ErrorHandler:

MsgBox "Cannot initialize SoapClient. " & Err.Description, vbExclamation

==============================================

This is a succesfull function

'Submits a single message to the service
Public Function SEND_SM(ByVal User As String, ByVal Password As String, ByVal Destination As String, ByVal Message As String)

As Recordset

'Create the XML DOM object
Dim xmlObj As MSXML2.IXMLDOMNodeList

'Set the DOM object to the required web service result
Set xmlObj = XMLCLASS.SEND_SM(User, Password, Destination, Message)

'Converts the result XML file into a Recordset this function works beatifully by stepping through the nodes
Set SEND_SM = ConvertXMLtoRecordset(xmlObj, "SEND_SM")

End Function

==============================================

This is how I am parsing the xml file into the DOM Document with no error.

'Create a schema cache and add books.xsd to it.
Dim xmlschema As MSXML2.XMLSchemaCache40
Set xmlschema = New MSXML2.XMLSchemaCache40
xmlschema.Add "http://www.tempuri.org/SEND_SM_BATCH.xsd", App.Path & "\SEND_SM_BATCH.xsd"

'Create an XML DOMDocument object.
Dim xmldom As MSXML2.DOMDocument40
Set xmldom = New MSXML2.DOMDocument40

'Assign the schema cache to the DOM document.
'schemas collection.
Set xmldom.schemas = xmlschema

'Load books.xml as the DOM document.
xmldom.async = False
xmldom.Load App.Path & "\SEND_SM_BATCH.xml"

'Return validation results in message to the user.
If xmldom.parseError.errorCode <> 0 Then
MsgBox xmldom.parseError.errorCode & " " & _
xmldom.parseError.reason
Else
MsgBox "No Error"
End If
Call XMLCLASS.SEND_SM_BATCH(xmldom)

==============================================

This is the function that fails when I attempt to send the DOMDocument , I have attempted to send a XML file , a recordset

all failing. This DomDocument seems to be the best way to go through SOAP

'Create the XML DOM object
Dim xmlObj As MSXML2.IXMLDOMNodeList

'Set the DOM object to the required web service result
'This is where I get a error : 'SoapMapper: Saving SoapMapper ds failed
Call XMLCLASS.SEND_SM_BATCH(xmldom)
'Set xmlObj = XMLCLASS.SEND_SM_BATCH(xmldom)

'Converts the result XML file into a Recordset
Set SEND_SM_BATCH = ConvertXMLtoRecordset(xmlObj, "SEND_SM")

Any advise / direction / assistance would be greatly appreciated.
Regards Leechie
 

Attachments

Back
Top