469,076 Members | 1,343 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,076 developers. It's quick & easy.

VB.NET Webservice Client - NOT to use SOAP Toolkit 3

Hi,

I have a successful VB6 web service client that uses the SOAP Toolkit 3
to make calls to a web service written in ASP.Net (VB.Net). However,
due to Microsoft not recommending the use of SOAP Toolkit 3 on a
Windows 2003 server, I must scrap the use of the toolkit and look to
develop the client in VB.Net instead.

I have upgraded the VB6 application to VB.Net using the built-in
upgrade tool that comes with Visual Studio .Net 2003. The majority of
the code has been translated to .Net, but I am having trouble as the
SOAP Toolkit 3 code has also been translated to VB.Net.

I have successfully called the web service to return very simple
values, where I do not actually need to use objects such as:
WSDLReader30, SoapSerializer30, SoapReader30, SoapConnector30 that are
required in the VB6 application. Am I correct to assume this??

I would appreciate if someone could advise me on how I should tackle
translating the following VB6 function that uses SOAP Toolkit 3.

The VB6 function is as follows:

Private Function ExecuteSOAP(aOperation() As String, xmlparams As
IXMLDOMNode, bErrorOnNoSOAP As Boolean) As SoapReader30

Dim WSDLReader As New WSDLReader30
Dim serializer As SoapSerializer30
Dim Reader As New SoapReader30
Dim Connector As New SoapConnector30
Dim ServiceEnumerator As IEnumWSDLService, Service As IWSDLService
Dim Fetched As Long
Dim PortEnumerator As IEnumWSDLPorts, Port As IWSDLPort
Dim OperationEnumerator As IEnumWSDLOperations, Operation As
IWSDLOperation
Dim MapperEnumerator As IEnumSoapMappers, Mapper As ISoapMapper
Dim bFoundOperation As Boolean
Dim XMLElement As IXMLDOMNode

'read WSDL file
On Error GoTo ErrorHandler

WSDLReader.Load gWSDL, ""

' Loop round the services
WSDLReader.GetSoapServices ServiceEnumerator
ServiceEnumerator.Next 1, Service, Fetched
Do While Fetched = 1 And bFoundOperation = False

' Loop round the ports
Service.GetSoapPorts PortEnumerator
PortEnumerator.Next 1, Port, Fetched
Do While Fetched = 1 And bFoundOperation = False

' find the operation
Port.GetSoapOperations OperationEnumerator

' The Find method returns an error if it fails so trap it
and continue
Set Operation = Nothing
On Error Resume Next
OperationEnumerator.Find aOperation(1), Operation
On Error GoTo ErrorHandler

If Not Operation Is Nothing Then
' prepare request
bFoundOperation = True
Set MapperEnumerator =
Operation.InputMessage.MessageParts

MapperEnumerator.Next 1, Mapper, Fetched
Do While Fetched = 1
'See if this is a complex type. The SchemaNode
property is nothing if simple type
If Mapper.SchemaNode Is Nothing Then
' simple type, just get the parameter from the
input xml file
If Not xmlparams.selectSingleNode("//" &
Mapper.ElementName) Is Nothing Then
Mapper.ComValue =
xmlparams.selectSingleNode("//" & Mapper.ElementName).Text
Else
Mapper.ComValue = ""
End If
Else
'complex type, use the whole node from the
input xml file
Mapper.ComValue = ""
If Not xmlparams.selectSingleNode("//" &
Mapper.ElementName) Is Nothing Then
'Mapper.ComValue =
xmlparams.selectSingleNode("//" & Mapper.ElementName).xml
For Each XMLElement In
xmlparams.selectSingleNode("//" & Mapper.ElementName).childNodes
Mapper.ComValue = Mapper.ComValue &
XMLElement.xml
Next
End If
End If
MapperEnumerator.Next 1, Mapper, Fetched
Loop

End If

If bFoundOperation = False Then PortEnumerator.Next 1,
Port, Fetched
Loop

If bFoundOperation = False Then ServiceEnumerator.Next 1,
Service, Fetched
Loop

If bFoundOperation = False Then
Set ExecuteSOAP = Nothing
Else
Set Connector = New HttpConnector30

strDebugPoint = "Connecting to port '" & Port.Address & "'"
Connector.ConnectWSDL Port

Connector.BeginMessageWSDL Operation

Set serializer = New SoapSerializer30
serializer.Init Connector.InputStream

serializer.StartEnvelope
serializer.StartBody

Operation.Save serializer, True

serializer.EndBody

' Force the message to appear on the screen
DoEvents

serializer.EndEnvelope

Connector.EndMessage

Reader.Load Connector.OutputStream

Set ExecuteSOAP = Reader
End If
Exit Function
Many thanks.

Jimmy

Jan 24 '06 #1
0 4337

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Q. John Chen | last post: by
1 post views Thread by Vincenzo Milazzo | last post: by
1 post views Thread by NN | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.