I am having problems sending xml document using soap 1.2 in vb6

Posted on 2012-08-30
Last Modified: 2012-09-15
I am having problems sending xml document using soap 1.2 in vb6. i AM receiving no errors
i dont know what I a, doing wrong

'Written by Igor Ostrovsky (
'Visual Basic 911 (
Option Explicit
Dim ErrDescription As String
Public filepath As String
Public xmlReader As New DOMDocument
Public ErrNumber As String
Const strURL = ""
Private Sub cmd_dialog_Click()
cmdDialog.DialogTitle = "Select A XML Request File."
cmdDialog.FileName = ""

cmdDialog.InitDir = "C:\tmp\"
cmdDialog.Flags = "&H80000" ' Use the Explorer-like Open A File dialog box template. Common dialogs that use this flag do not work under Windows NT using the Windows 95 shell.
cmdDialog.Filter = "XML Files (*.XML)|*.XML"
cmdDialog.FilterIndex = 1
End Sub

Private Sub cmdRequest_Click()
  Dim o As New xmlHttp
  Dim s As String
  Dim DocToSend As MSXML2.DOMDocument
  Dim XMLManager As DOMDocument
  Dim strXML As String

On Error GoTo err_handler

filepath = cmdDialog.FileName
'cmdDialog.CancelError = True
If Err.Number = cdlCancel Then
    Exit Sub
End If

Set DocToSend = New MSXML2.DOMDocument

    If Not ReadXMLDocument(filepath, DocToSend) Then
        MsgBox "Cannot read " & filepath & vbCrLf & Err.Number & ", " & Err.ErrDescription, vbCritical
        Exit Sub
    End If
    If SendRequestXML(DocToSend, strXML, strURL) Then
       xml_responce.Text = strXML
        MsgBox "Cannot send " & DocToSend.xml & vbCrLf & Err.Number & ", " & Err.ErrDescription, vbCritical
        Exit Sub
    End If
        Set DocToSend = Nothing
    Exit Sub

  If Err.Number <> 0 Then MsgBox "Error " & Err.Number & ": " & Err.Description
End Sub

Private Sub Form_Load()
End Sub

Private Function SendRequestXML(ByRef pXMLDoc As MSXML2.DOMDocument, ByRef pcTmp As String, ByVal pstrURL As String) As Boolean
    Dim SoapActionUrl As String
    Dim xmlHttp As MSXML2.XMLHTTP40
On Error GoTo err_SendRequestXML
    SendRequestXML = False
    Set xmlHttp = New MSXML2.XMLHTTP40
    SoapActionUrl = "" "POST", pstrURL, True ' False - syncronous mode
    'xmlHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
    xmlHttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
    xmlHttp.setRequestHeader "Content-Length", CStr(Len(pXMLDoc.xml))
    xmlHttp.setRequestHeader "SOAPAction", SoapActionUrl
    xmlHttp.send pXMLDoc.xml
    xml_request.Text = pXMLDoc.xml
    pcTmp = xmlHttp.responseXML.xml
    xml_responce.Text = xmlHttp.responseXML.xml
    Set xmlHttp = Nothing
    SendRequestXML = True
    Exit Function

    If IsObject(xmlHttp) Then Set xmlHttp = Nothing
    ErrNumber = Err.Number
    ErrDescription = "Run-time ERROR in SendRequestXML. " & Err.Description
End Function

Private Function ReadXMLDocument(ByVal pDocName As String, ByRef pXMLDoc As MSXML2.DOMDocument) As Boolean

    On Error GoTo err_ReadXMLDocument

    ReadXMLDocument = False

    pXMLDoc.async = False
    pXMLDoc.resolveExternals = False    ' otherwise you must have a refered DTD
    pXMLDoc.validateOnParse = False     ' in a same directory
    pXMLDoc.Load pDocName
    If pXMLDoc.parseError.errorCode = 0 Then
        ReadXMLDocument = True
        ErrNumber = pXMLDoc.parseError.errorCode
        ErrDescription = "Errors in " & pXMLDoc.parseError.url & ", line " & pXMLDoc.parseError.Line & ", pos " & pXMLDoc.parseError.linepos
        ErrDescription = Err.ErrDescription & ". Error #" & Err.Number & ". " & pXMLDoc.parseError.reason
    End If

Exit Function
    ErrNumber = Err.Number
    ErrDescription = "Run-time ERROR in ReadXMLDocument " & Err.Description & " for " & pDocName
End Function

Open in new window

here is the xml file

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap12="">
    <GetCarrierQuote xmlns="">

Open in new window

Question by:1030071002

    Author Comment

    header info

    POST /ws/gmgservice.asmx HTTP/1.1
    Content-Type: application/soap+xml; charset=utf-8
    Content-Length: length
    LVL 44

    Assisted Solution

    have you stepped through your code and know that it is executing the send code?
    how do you know it isn't working?

    Author Comment

    yes I have done that. everything is working the send works but I dont get any responce
    I am also using soap 1.2
    LVL 44

    Assisted Solution

    what kind of response are you expecting?
    LVL 15

    Accepted Solution

    Have you tried:
        xml_request.Text = xmlHttp.responseText
    Instead of:
        xml_responce.Text = xmlHttp.responseXML.xml

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now