Skip to main content

[archive] Passing data between classes

  • July 14, 2006
  • 11 replies
  • 0 views

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).

11 replies

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
The only way I can think of, would be if hXML-Document can be associated with hXML-http in such a way as for instance the msmapi32 associates sessions and messages.

I assume what you ask for is if it would be possible to do something like this:

MODIFY hXML-DOCUMENT @LoadXML (hXML-HTTP @responseText) GIVING WS-RETURNVAL.

Unfortunately, we do not currently support this syntax.

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
:(
The only way I can think of, would be if hXML-Document can be associated with hXML-http in such a way as for instance the msmapi32 associates sessions and messages.

I assume what you ask for is if it would be possible to do something like this:

MODIFY hXML-DOCUMENT @LoadXML (hXML-HTTP @responseText) GIVING WS-RETURNVAL.

Unfortunately, we do not currently support this syntax.


Yes! thats exactly what I want to do, the trouble is the responseText can be very large in some cases I don't even know how big and if I limit it with a variable I may be truncating some of the data without realizing it... There is a PROPERTY-GET @ResponseXML that returns an IDispatch (pointer?) in hXML-HTTP. I have tried this but I cannot get hXML-Document to load from a pointer (handle)... :(

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
:(
The only way I can think of, would be if hXML-Document can be associated with hXML-http in such a way as for instance the msmapi32 associates sessions and messages.

I assume what you ask for is if it would be possible to do something like this:

MODIFY hXML-DOCUMENT @LoadXML (hXML-HTTP @responseText) GIVING WS-RETURNVAL.

Unfortunately, we do not currently support this syntax.


Yes! thats exactly what I want to do, the trouble is the responseText can be very large in some cases I don't even know how big and if I limit it with a variable I may be truncating some of the data without realizing it... There is a PROPERTY-GET @ResponseXML that returns an IDispatch (pointer?) in hXML-HTTP. I have tried this but I cannot get hXML-Document to load from a pointer (handle)... :(

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
here is a sample in VB of just about exactly what I want to accomplish. Can anyone give me the equivalent in COBOL for the highlighted line?

Public oHttpReq As XMLHTTP30
Public oXMLDoc As DOMDocument30

Private Sub Command1_Click()
    MakeRequest (True)
End Sub

Private Sub MakeRequest(ByVal isAsync As Boolean)
    Set oHttpReq = New XMLHTTP30
    Dim xhrHandler As myHttpRequestHandlers

    If isAsync = True Then
        Set xhrHandler = New myHttpRequestHandlers
       
        ' Set a readyStateChange handler.
        oHttpReq.OnReadyStateChange = xhrHandler
    End If
   
    ' Construct the URL from user input.
    url = Text1.Text
    If Text2.Text <> "" Then
        url = url "?SearchID=" Text2.Text
    End If
    ' Clear the display.
    Text3.Text = ""
   
    ' Open a connection and set up a request to the server.
    oHttpReq.open "GET", url, isAsync
       
    ' Send the request to the server.
    oHttpReq.send
   
    ' In a synchronous call, we must call ProcessResponse. In an
    ' asynchronous call, the OnReadyStateChange handler calls
    ' ProcessResponse.
    If isAsync = False Then
        ProcessResponse
    End If
End Sub
Public Sub ProcessResponse()
[B][COLOR="Red"]   ' Receive the response from the server.
    Set oXMLDoc = oHttpReq.responseXML[/COLOR][/B]
   
    ' Display the server response to the user.
    Set oNode = oXMLDoc.selectSingleNode("//phone")
    If oNode Is Nothing Then
        Text3.Text = "Requested information not found."
    Else
        Text3.Text = oNode.Text
    End If
End Sub

Private Sub Form_Load()
    Text3.Text = ""
    Text1.Text = "localhost/.../contact.asp"
    Text2.Text = "John Doe"
End Sub

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
here is a sample in VB of just about exactly what I want to accomplish. Can anyone give me the equivalent in COBOL for the highlighted line?

Public oHttpReq As XMLHTTP30
Public oXMLDoc As DOMDocument30

Private Sub Command1_Click()
    MakeRequest (True)
End Sub

Private Sub MakeRequest(ByVal isAsync As Boolean)
    Set oHttpReq = New XMLHTTP30
    Dim xhrHandler As myHttpRequestHandlers

    If isAsync = True Then
        Set xhrHandler = New myHttpRequestHandlers
       
        ' Set a readyStateChange handler.
        oHttpReq.OnReadyStateChange = xhrHandler
    End If
   
    ' Construct the URL from user input.
    url = Text1.Text
    If Text2.Text <> "" Then
        url = url "?SearchID=" Text2.Text
    End If
    ' Clear the display.
    Text3.Text = ""
   
    ' Open a connection and set up a request to the server.
    oHttpReq.open "GET", url, isAsync
       
    ' Send the request to the server.
    oHttpReq.send
   
    ' In a synchronous call, we must call ProcessResponse. In an
    ' asynchronous call, the OnReadyStateChange handler calls
    ' ProcessResponse.
    If isAsync = False Then
        ProcessResponse
    End If
End Sub
Public Sub ProcessResponse()
[B][COLOR="Red"]   ' Receive the response from the server.
    Set oXMLDoc = oHttpReq.responseXML[/COLOR][/B]
   
    ' Display the server response to the user.
    Set oNode = oXMLDoc.selectSingleNode("//phone")
    If oNode Is Nothing Then
        Text3.Text = "Requested information not found."
    Else
        Text3.Text = oNode.Text
    End If
End Sub

Private Sub Form_Load()
    Text3.Text = ""
    Text1.Text = "localhost/.../contact.asp"
    Text2.Text = "John Doe"
End Sub

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
Assuming:
77 oXMLDoc HANDLE OF DOMDocument30

Your bold should translate to:
INQUIRE oHttpRq resposeXML oXMLDoc IN oHttpReq.responseXML

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
Assuming:
77 oXMLDoc HANDLE OF DOMDocument30

Your bold should translate to:
INQUIRE oHttpRq resposeXML oXMLDoc IN oHttpReq.responseXML


Call me crazy, but this doesn't look like valid code. Is it valid or are you just trying to make a point? Referring back to my original code and using what you have suggested here this is what I came up with but it will not compile I get the following two errors:

Identifier unresolved: HXML-DOCUMENT OF HXML-HTTP
Verb expected, RESPONSEXML found


CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** So instead of doing this
* INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
* MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
*MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).

**** I now tried your suggestion
INQUIRE hXML-HTTP @responseXML hXML-DOCUMENT IN hXML-HTTP.responseXML.

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
Assuming:
77 oXMLDoc HANDLE OF DOMDocument30

Your bold should translate to:
INQUIRE oHttpRq resposeXML oXMLDoc IN oHttpReq.responseXML


Call me crazy, but this doesn't look like valid code. Is it valid or are you just trying to make a point? Referring back to my original code and using what you have suggested here this is what I came up with but it will not compile I get the following two errors:

Identifier unresolved: HXML-DOCUMENT OF HXML-HTTP
Verb expected, RESPONSEXML found


CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** So instead of doing this
* INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
* MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
*MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).

**** I now tried your suggestion
INQUIRE hXML-HTTP @responseXML hXML-DOCUMENT IN hXML-HTTP.responseXML.

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
Sorry for making a typo.
This was what I had in mind.

INQUIRE oHttpRq responseXML IN oXMLDoc.

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
Sorry for making a typo.
This was what I had in mind.

INQUIRE oHttpRq responseXML IN oXMLDoc.

[Migrated content. Thread originally posted on 13 July 2006]

Any ideas woudl be most helpful,

I retrieved some xml data using the MSXML50.DEF object. The data sits in @responseText of the XMLHTTP50 Object. Since it is VERY large I want to get it into DOMDocument50 Object and then use @Save to save it out to a file.

Here is the code snippet:

CREATE @DOMDocument50 HANDLE IN hXML-DOCUMENT.
CREATE @XMLHTTP50 HANDLE IN hXML-HTTP.

MODIFY hXML-HTTP @Open("POST", WS-URL, 0).
MODIFY hXML-HTTP @setRequestHeader("Content-Type", "application/x-www-form-urlencoded").
MODIFY hXML-HTTP @Send (WS-DATA-TO-SEND).
INITIALIZE WS-STATUS.
INQUIRE hXML-HTTP @Status IN WS-STATUS.
IF WS-STATUS = 200

**** I want to avoid putting this to a variable first and just go straight into the other object, is this possible?
INQUIRE hXML-HTTP @responseText IN WS-XML-DATA
MODIFY hXML-DOCUMENT @LoadXML (WS-XML-DATA) GIVING WS-RETURNVAL.
MODIFY hXML-DOCUMENT @Save (WS-FULL-FILENAME).
Thanks,

That was the first thing I tried before I posted here. For some reason it does not populate the Document Class with the XML text, I must be missing something or cobol doesn't work quite like VB when using this syntax.