Login  
Search All Forums
Dart Home | PowerTCP Web for ActiveX | Custom Development Reply | PowerTCP Web for ActiveX Topics | Forums   
AuthorForum: PowerTCP Web for ActiveX
Topic: Non-blocked http post
User890

Posts: 1
Member Since: 02/27/01
posted February 27, 2001 11:53 AM

I'm attempting to do an http post with timeout = 0. I'm not getting any errors put the post does not complete. Also the Progress event seems to give bogus data for Count and Size ie, first pass count=100 size=100, second pass count=5 size=5. Can anyone give me a simple example of how to do a non-blocking Post? Thanks.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted February 27, 2001 12:23 PM


Let's start simple. Replace the code in the VB Post sample with this:

'*******************************************************************
' Program: PowerTCP Non-Blocking Post
' Author:  Tony Priest
' Date:   2/27/01
'
' Purpose: To demonstrate how to use PowerTCP to use Http to post
'      some items to a web page.
'********************************************************************}
Option Explicit
Private m_bAborted As Boolean
Private m_bError As Boolean
Dim Data As String

Private Sub cmdPost_Click()
  m_bError = False
  lblStatus = "Posting to Dart..."
  Http1.Timeout = 0
  Http1.Url = "http://www.dart.com/PostSample.asp"
  Http1.Post GetPostString, , Data
End Sub

Private Function GetPostString() As String
  Dim s As String
  s = "Item1=" + txtItem(0).Text
  s = s + "&Item2=" + txtItem(1).Text
  s = s + "&Item3=" + txtItem(2).Text
  s = Replace(s, " ", "%20") ' replace spaces
  GetPostString = s
End Function

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  ' Dont let the app exit while busy doing the POST
  If Http1.Blocked Then
    Cancel = 1
    m_bAborted = True
  End If
End Sub

Private Sub cmdAbout_Click()
  Dim frm As frmAbout
  Set frm = New frmAbout
  frm.lblTitle = "Web Post"
  frm.Show vbModal
  Set frm = Nothing
End Sub

Private Sub Form_Resize()
  If WindowState = vbMinimized Then Exit Sub
  If Height < 5130 Then Height = 5130
  If Width < 6105 Then Height = 6105
  With lblStatus
    .Left = 0
    .Width = ScaleWidth
  End With
  With txtResponse
    .Left = 0
    .Width = ScaleWidth
    .Height = ScaleHeight - .Top
  End With
End Sub

Private Sub Http1_Error(ByVal Number As DartWebCtl.ErrorConstants, ByVal Description As String)
  lblStatus = "Error, Number: " + Str(Number) + " Desc: " + Description
  m_bError = True
  If m_bAborted Then Unload Me
End Sub

Private Sub Http1_Progress(ByVal Count As Long, ByVal Size As Long)
  Debug.Print "PROGRESS EVENT: ", Count, Size
End Sub

Private Sub Http1_State()
  Debug.Print "STATE EVENT: ", Http1.State
  If Http1.State = httpCompleted Then
    If Not m_bError Then
      lblStatus = "Post successful!"
      txtResponse.Text = Data
    End If
  End If
End Sub
tear_catcher

From: Durham, NC USA
Posts: 4
Member Since: 11/09/05
posted November 9, 2005 2:14 PM

I have been running into some troubles attempting to upgrade our VB6 client application to VB.NET. I found this posting and I used it as a starting point. I pasted the code below over top the VB6 Post Demo and everything worked fine. I then upgraded the Demo to VB.Net and I cannot get things to work. Specifically, the Post completes without error, but the response Data is empty. I have replicated this same behavior using the PowerTCP Debug Server. Any ideas? Here is the migrated VB.NET code:
'*******************************************************************
' Program: PowerTCP Non-Blocking Post
' Author: Tony Priest
' Date:  2/27/01
'
' Purpose: To demonstrate how to use PowerTCP to use Http to post
'   some items to a web page.
'********************************************************************}
Private m_bAborted As Boolean
Private m_bError As Boolean
Dim Data As String

Private Sub cmdPost_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPost.Click
m_bError = False
lblStatus.Text = "Posting to Dart..."
Http1.Timeout = 0
Http1.Url = "http://www.dart.com/PostSample.asp"
Http1.Post(GetPostString, , Data)
End Sub

Private Function GetPostString() As String
Dim s As String
s = "Item1=" & txtItem(0).Text
s = s & "&Item2=" & txtItem(1).Text
s = s & "&Item3=" & txtItem(2).Text
s = Replace(s, " ", "%20") ' replace spaces
GetPostString = s
End Function

'UPGRADE_WARNING: Form event frmMain.QueryUnload has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2065"'
Private Sub frmMain_Closing(ByVal eventSender As System.Object, ByVal eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim Cancel As Short = eventArgs.Cancel
' Dont let the app exit while busy doing the POST
If Http1.Blocked Then
Cancel = 1
m_bAborted = True
End If
eventArgs.Cancel = Cancel
End Sub

Private Sub cmdAbout_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdAbout.Click
Dim frm As frmAbout
frm = New frmAbout
frm.lblTitle.Text = "Web Post"
frm.ShowDialog()
'UPGRADE_NOTE: Object frm may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
frm = Nothing
End Sub

'UPGRADE_WARNING: Event frmMain.Resize may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2075"'
Private Sub frmMain_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize
If WindowState = System.Windows.Forms.FormWindowState.Minimized Then Exit Sub
If VB6.PixelsToTwipsY(Height) < 5130 Then Height = VB6.TwipsToPixelsY(5130)
If VB6.PixelsToTwipsX(Width) < 6105 Then Height = VB6.TwipsToPixelsY(6105)
With lblStatus
.Left = 0
.Width = ClientRectangle.Width
End With
With txtResponse
.Left = 0
.Width = ClientRectangle.Width
.Height = VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(ClientRectangle.Height) - VB6.PixelsToTwipsY(.Top))
End With
End Sub

Private Sub Http1_Error(ByVal eventSender As System.Object, ByVal eventArgs As AxDartWeb._IHttpEvents_ErrorEvent) Handles Http1.Error
lblStatus.Text = "Error, Number: " & Str(eventArgs.Number) & " Desc: " & eventArgs.Description
m_bError = True
If m_bAborted Then Me.Close()
End Sub

'UPGRADE_NOTE: Size was upgraded to Size_Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"'
Private Sub Http1_Progress(ByVal eventSender As System.Object, ByVal eventArgs As AxDartWeb._IHttpEvents_ProgressEvent) Handles Http1.Progress
System.Diagnostics.Debug.WriteLine(VB6.TabLayout("PROGRESS EVENT: ", eventArgs.Count, eventArgs.Size))
End Sub

Private Sub Http1_StateEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Http1.StateEvent
System.Diagnostics.Debug.WriteLine(VB6.TabLayout("STATE EVENT: ", Http1.CtlState))
If Http1.CtlState = DartWeb.StateConstants.httpCompleted Then
If Not m_bError Then
lblStatus.Text = "Post successful!"
txtResponse.Text = Data
End If
End If
End Sub
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted November 9, 2005 2:44 PM

Have you looked at the VB.NET sample yet? It seems to work fine for me.

tear_catcher

From: Durham, NC USA
Posts: 4
Member Since: 11/09/05
posted November 9, 2005 2:57 PM

Yes, the VB.NET sample works, but it is a blocking sample and I am looking for a non-blocking sample that works using VB.NET. Thanks.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted November 9, 2005 3:10 PM

How did you get VB.NET to compile with this line?:

 Http1.Post(GetPostString, , Data)

tear_catcher

From: Durham, NC USA
Posts: 4
Member Since: 11/09/05
posted November 9, 2005 3:21 PM

I am not sure how to answer this question. I am using Visual Studio 2003 and I just did a rebuild all and everything succeeded. I am rather new to VB.NET, should that not build? What is the error that you get?
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted November 9, 2005 4:17 PM

It should give an error because VB.NET does not support that form of optional parameter passing. I had to change it to:

Http1.Post(Data, Nothing, m_Result, Nothing, "", "")

In any event, I have confirmed the issue. Unfortunately, I don't have a work-around, other than to tell you not to use .NET or use blocking mode.

tear_catcher

From: Durham, NC USA
Posts: 4
Member Since: 11/09/05
posted November 10, 2005 9:48 AM

Is this going to be fixed in a subsequent release? Is there a .NET version of the web tool scheduled (I do not see one currently available)? Do you have another product that solves this problem, perhaps the WebASP control? Do none of your other customers use non-blocking mode in .NET?

I may be able to use the blocking mode of the control, but I it seems to me that if you are going to make the statement that your control is "100% .NET compatible using .NET COM interop" that this should work. I am trying to get some information as this could affect our scheduled migration from VB6 to VB.NET.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted November 10, 2005 3:00 PM

Yes, it will be fixed in a future release, but there is not one currently on the schedule. WebASP should work OK (I have no reason to suspect it wouldn't)

We don't plan on making one for .NET because there is one built it already that most people seem to use.

Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted September 12, 2006 3:29 PM

Update: This ended up being something we could not fix without a redesign of the Get and Post methods. Here is why: When you pass in an empty string into the Get or Post methods, Visual Studio passes the parameter in by value instead of by reference as is clearly defined in our IDL. This causes us to overwrite memory when used in non-blocking mode.

Subsequent releases of the Web tool will throw an invalid parameter error when this condition is discovered.
marcq

From: Slidell, LA USA
Posts: 2
Member Since: 05/28/05
posted November 26, 2007 12:51 PM

I assume this is still the case? I find myself in desperate need of doing non-blocking GETs and POSTs in .NET. If Dart Web ActiveX still will not do non-blocking in .NET, what are my alternatives?

Thanks in advance...
Amit

From: Rome, NY USA
Posts: 315
Member Since: 03/15/06
posted November 26, 2007 3:59 PM

Hello,

As suggested already in this post, I would suggest you to please download WebASP control. You may install a trial of this control from following location:

http://dart.com/ptwbe_trial.aspx

Best Regards,
Amit

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted November 27, 2007 9:58 AM

Hi,
We've looked into this, and have discovered the source of the problem.
It was previously stated that a rewrite would be required.
This is actually not the case, and the next update should be useable in .NET.

We are also considering an HTTP native-.NET product.
May I ask why you prefer to use the ActiveX control over the Framework HttpWebRequest class?

Thanks,
-ken
Reply | PowerTCP Web for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX