Call simple web service via Soap Client

I am new Soap in VB 6.  I thought I'd be able to just figure it out as I normally do.  However this proved to be a slow process because I cannot find a help file that contains description of the SoapClient object methods, properties etc.  I am looking a code sample that calls a service passes a name (string) then returns "hello" & name - that simple.  I am also looking for the location of the Soap toolkit help file (I have soap toolkit installed) This is actually more important than the sample

Many thanks
LVL 12
Who is Participating?
gbzhhuAuthor Commented:
Both didn't help

First one
I am already to create the soapclient object and successfully call MSSoapInit method.  I didn't know where to go from there.  How to call the SayHi method of my service and pass a string to it displaying the returned string.  The service is written in Java (J2EE).  When I tried soapclient.SayHi("MyName") I get an error saying

No Deserializer found to deserialize a ':name' using encoding style ''.

The second one is for Office VBA.  I need this from VB 6.  I only have Office 97 anyway which doesn't support all that stuff

gbzhhuAuthor Commented:
Ok, go it fixed

This is the page that helped me

And this is my code as it stands, so I hope it helps someone else someday.  Live long EE

Option Explicit

Private Const ENC = ""
Private Const XSI = ""
Private Const XSD = ""
Private Const URL = "http://ourserver:9888/WS_Hello01/servlet/rpcrouter"
Private Const URI = "uri:HiWebService"
'Private Const URI = ""
Private Const Method = "sayHello"

Private Sub Command1_Click()
    'Instantiate your SOAP Connector, Serializer and Reader. The Connector will handle the HTTP Connection, the Serializer will help you build the SOAP Envelope and the Reader will help you to access the result.
    Dim Connector As SoapConnector30
    Dim Serializer As SoapSerializer30
    Dim Reader As SoapReader30
    Set Connector = New HttpConnector30
    Set Serializer = New SoapSerializer30
    Set Reader = New SoapReader30
    'Prepare the Connector to talk to the SOAP Server. Note that the "SoapAction" data is not consequential on the server side so the contents can be anything at all - It is a good idea to set it to the URI and Method name for easier identification when you are debugging and reading the SOAP messages.
    Connector.Property("EndPointURL") = URL
    Call Connector.Connect
    Connector.Property("SoapAction") = URI & "#" & Method
    Call Connector.BeginMessage
    'Associate your Serializer with your Connector.
    Serializer.Init Connector.InputStream
    'Start the SOAP Envelope and specify the Encoding and XML-Schema.
    Serializer.StartEnvelope , ENC
    Serializer.SoapNamespace "xsi", XSI
    Serializer.SoapNamespace "SOAP-ENC", ENC
    Serializer.SoapNamespace "xsd", XSD
    'Start the body of the message - the root element is always the Service URI and method.
    Serializer.StartElement Method, URI, , "method"
    'Write each method parameter out as a child to the root element.
    Serializer.StartElement "name"
    Serializer.SoapAttribute "type", , "xsd:string", "xsi"
    Serializer.WriteString "Hassan"
    'End the root element, the body and the envelope.
    'Ending the message causes it to be sent.
    'Load the result into the Reader.
    Reader.Load Connector.OutputStream
    'If no fault loading the Reader then you can go ahead and pull the result of the invocation out of the DOM (Document Object Model) contained in the reader. There are many ways to do this ranging from methods highly specialised to the task at hand (and thus quite efficient) to more general and reusable methods that are not so efficient (like the method you will see in the downloadable source).
    If Not Reader.Fault Is Nothing Then
      MsgBox Reader.FaultString.Text, vbExclamation
MsgBox Reader.Dom.Text
    End If

End Sub

gbzhhuAuthor Commented:
Aryaomni,  I'll accept your answer as you are the one who tried to help.  Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.