I am building a VB.NET web service connecting to Tamino 4.1.4 using the 4.1.5.1 API.
The following function works if I use autocommit (and comment ou the BeginTransaction) but with LocalTransaction, it hangs (though the data is wrtieen to tamino, and even if I do a stop of the database using roll-back the data is still in tamino).
(Sorry for the lack for formatting, it seems your input removes the tabs that make the code easier to follow.)
<WebMethod()> Public Function SaveDynaFormDoc(ByVal TaminoDB As String, ByVal strCollection As String, ByVal strXML As String) As String
Dim tConn As TaminoConnection
Dim tCom As TaminoCommand
Dim tDom As TaminoDocument
Dim tTran As TaminoTransaction
Dim tResponse As TaminoResponse
Dim strError As String
Dim oDom As New Xml.XmlDocument
Dim tPref As New TaminoPreference
Dim tUser As New TaminoUserInfo(“”, “”)
Try
oDom.LoadXml(strXML)
tDom = New TaminoDocument(oDom)
tPref.NonActivityTimeout = 20
tPref.TransactionTimeout = 20
tConn = New TaminoConnection(TaminoDB, tUser, tPref)
tConn.Open(TaminoConnectionMode.LocalTransaction)
'tConn.Open(TaminoConnectionMode.AutoCommit)
tCom = tConn.CreateCommand(strCollection)
Catch ex As Exception
strError = String.Concat("Unexpected error connecting to Tamino. ;; Error_Message: ", ex.Message, Constants.vbCrLf, " ;; Stack_Trace: ", ex.StackTrace)
tConn.Close()
Return String.Concat(“Fail: Standard Exception,”, strError)
End Try
Try
tTran = tConn.BeginTransaction()
tResponse = tCom.Insert(tDom)
If Not tResponse.ReturnValue = “0” Then
strError = tResponse.ErrorText
If tConn.IsInTransaction Then
tTran.Rollback()
End If
tConn.Close()
Return String.Concat("Fail: ", strError)
Else
If tConn.IsInTransaction Then
tTran.Commit()
End If
tConn.Close()
Return "Success " & tResponse.ReturnValue
End If
Catch tExcp As TaminoException
strError = String.Concat("A WebException has been caught. ", tExcp.ToString(), tExcp.TargetSite.Name)
If tConn.IsInTransaction Then
tTran.Rollback()
End If
tConn.Close()
Return String.Concat(“Fail: Tamino Exception,”, strError)
Catch webExcp As WebException
strError = String.Concat("A WebException has been caught. ", webExcp.ToString())
Dim status As WebExceptionStatus = webExcp.Status
’ If status is WebExceptionStatus.ProtocolError,there has been a protocol error and a WebResponseshould exist. Display the protocol error.
If status = WebExceptionStatus.ProtocolError Then
strError = strError & "The server returned protocol error "
’ Get HttpWebResponse so that you can check the HTTP status code.
Dim httpResponse As HttpWebResponse = CType(webExcp.Response, HttpWebResponse)
strError = String.Concat(“Unexpected error executing transaction.”, strError, Int(httpResponse.StatusCode).ToString(), " - ", httpResponse.StatusCode.ToString())
End If
If tConn.IsInTransaction Then
tTran.Rollback()
End If
tConn.Close()
Return String.Concat(“Fail: Web Exception,”, strError)
Catch ex2 As Exception
strError = String.Concat("Unexpected error executing transaction. ;; Error_Message: ", ex2.Message, Constants.vbCrLf, " ;; Stack_Trace: ", ex2.StackTrace)
If tConn.IsInTransaction() Then
tTran.Rollback()
End If
tConn.Close()
Return String.Concat(“Fail: Standard Exception,”, strError)
End Try
End Function
#webMethods#API-Management#webMethods-Tamino-XML-Server-APIs