• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2110
  • Last Modified:

VB6 Soap

I have been tasked with creating a web services call through a VB6 application. I've added the SOAP 3.0 Toolkit and have the code below.

I'm trying to hit the FedEx web service. I've tried changing the init to FedEx, and I get error messages.
"WSDLReader:XML Parser failed at linenumber 0, lineposition 0, reason is: System error: -2146697210.
 HRESULT=0x1: Incorrect function.
 - WSDLReader:Loading of the WSDL file failed HRESULT=0x80070057: The parameter is incorrect.
 - Client:One of the parameters supplied is invalid. HRESULT=0x80070057: The parameter is incorrect."

I'm at a loss as to how I insert values into the call, I have the Request XML file and I know what I should be putting in there, but no idea how to actually send the correct information.

I've done web services development in .NET but that's not an option with this project.
Private Sub Command1_Click()
On Error GoTo error_Occured
Dim client
Set client = CreateObject("MSSOAP.SoapClient30")
client.mssoapinit "http://localhost/CF_WebSvc/justFunction.cfc?wsdl"

strg = (client.WelcomeMsg(Text1.Text))
MsgBox (strg)

Exit Sub

If Err.Number = -2147024809 Then
    MsgBox "Invalid Web Service Request. Please check the Web Service URL"
End If
GoTo exit_Function

End Sub

Open in new window

  • 2
  • 2
1 Solution
Set a reference to the Microsoft xml dll and try this code:

Sub soapDemo()

    Dim sURL As String
    Dim strXML As String
    Dim sEnv As String
    Dim xmlhtp As New MSXML2.XMLHTTP40
    Dim xmlDoc As New DOMDocument
    sURL = "http://webservices.gama-system.com/exchangerates.asmx?op=ConvertToForeign"
    sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
    sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
    sEnv = sEnv & "  <soap:Body>"
    sEnv = sEnv & "    <ConvertToEUR xmlns=""http://www.gama-system.com/webservices"">"
    sEnv = sEnv & "      <dcmValue>decimal</dcmValue>"
    sEnv = sEnv & "      <strBank>ING</strBank>"
    sEnv = sEnv & "      <strCurrency>USD</strCurrency>"
    sEnv = sEnv & "      <strDate>31-1-2008</strDate>"
    sEnv = sEnv & "      <intRank>1</intRank>"
    sEnv = sEnv & "    </ConvertToEUR>"
    sEnv = sEnv & "  </soap:Body>"
    sEnv = sEnv & "</soap:Envelope>"
    With xmlhtp
        .Open "post", sURL, False
        .setRequestHeader "Host", "webservices.gama-system.com"
        .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
        .setRequestHeader "soapAction", "http://www.gama-system.com/webservices/ConvertToForeign"
        .setRequestHeader "Accept-encoding", "zip"
        .send sEnv
        ' Next statement strips off the soap envelope and creates an XML document with just the results.
        xmlDoc.loadXML .responseText
        MsgBox .responseText
    End With
End Sub

Open in new window

And of course you need to build the proper envelope string which belongs to the webservice you are trying to address....
whsrptgAuthor Commented:
Is IIS required on all machines that run this, or just the server?
whsrptgAuthor Commented:
NM, It's only required on the server. thanks for your help that'll work out great!
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.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now