?
Solved

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

Posted on 2012-08-30
5
Medium Priority
?
1,338 Views
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 (info@ostrosoft.com)
'Visual Basic 911 (http://www.ostrosoft.com/vb)
'==============================================
Option Explicit
Dim ErrDescription As String
Public filepath As String
Public xmlReader As New DOMDocument
Public ErrNumber As String
Const strURL = "http://gmgtransport.com/ws/gmgservice.asmx"
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

cmdDialog.ShowOpen
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
    Else
        MsgBox "Cannot send " & DocToSend.xml & vbCrLf & Err.Number & ", " & Err.ErrDescription, vbCritical
        Exit Sub
    End If
        Set DocToSend = Nothing
    Exit Sub

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

Private Sub Form_Load()
cmdRequest_Click
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 = "http://tempuri.org/GetCarrierQuote"


    xmlHttp.open "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

err_SendRequestXML:
    If IsObject(xmlHttp) Then Set xmlHttp = Nothing
    ErrNumber = Err.Number
    ErrDescription = "Run-time ERROR in SendRequestXML. " & Err.Description
    Err.Clear
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
    Else
        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
err_ReadXMLDocument:
    ErrNumber = Err.Number
    ErrDescription = "Run-time ERROR in ReadXMLDocument " & Err.Description & " for " & pDocName
    Err.Clear
End Function

Open in new window


here is the xml file

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetCarrierQuote xmlns="http://tempuri.org/">
      <userName>peaches</userName>
      <password>salons</password>
      <carrierId>ODFL</carrierId>
      <customerId>PEACSALOH4C3C5_MOROCCANOILPH4</customerId>
      <sourceZip>07032</sourceZip>
      <sourceState>NJ</sourceState>
      <destinationZip>19006</destinationZip>
      <destinationState>PA</destinationState>
      <shipDate>2012-08-30</shipDate>
      <items>
        <QuoteLineItem>
          <Quantity>12</Quantity>
          <Unit>SKD</Unit>
          <Class>70.0</Class>
          <Weight>3000</Weight>
        </QuoteLineItem>
        <QuoteLineItem>
          <Quantity>2</Quantity>
          <Unit>SKD</Unit>
          <Class>50.0</Class>
          <Weight>200</Weight>
        </QuoteLineItem>
      </items>
      <accessorials>
      </accessorials>
    </GetCarrierQuote>
 </soap12:Body>
</soap12:Envelope>

Open in new window

0
Comment
Question by:1030071002
  • 2
  • 2
5 Comments
 

Author Comment

by:1030071002
ID: 38350864
header info

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

Assisted Solution

by:aikimark
aikimark earned 999 total points
ID: 38351811
have you stepped through your code and know that it is executing the send code?
how do you know it isn't working?
0
 

Author Comment

by:1030071002
ID: 38351899
yes I have done that. everything is working the send works but I dont get any responce
I am also using soap 1.2
0
 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 999 total points
ID: 38352098
what kind of response are you expecting?
0
 
LVL 15

Accepted Solution

by:
eemit earned 501 total points
ID: 38380751
Have you tried:
    xml_request.Text = xmlHttp.responseText
Instead of:
    xml_responce.Text = xmlHttp.responseXML.xml
0

Featured Post

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

749 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