Hello Experts.
I need your help, I am new to XML web service, and I have to complete one task.
Here is current situation.
1. I have web service running to recieve SOAP message from an external service and send message reciepts. This service Recieve XML as object and transforms into XML file and then imports that XML file into SQL Server database and then sends SOAP message reciept. I am not developer of that code, it is huge thousands of lines of code.
Now problem is when XML files recieved from multiple cleint at the same time, then importing of data process dies saying (Data reader already open).
*************** *************** ******
This is my code behind ASMX file - Public
-
-
Function ProcessMessage(ByVal MESSAGE As wgsserver.MESSAGE) As <System.Xml.Serialization.XmlElementAttribute("MESSAGE", [Namespace]:="http://ws.abc.com/fieldservices/ext/message-receipt.xsd")> wgsserver.MessageType
-
-
Dim returnMsg As wgsserver.MessageType
-
-
Try
-
-
'log the request message
-
-
Dim requestPath As String = Util.logRequestMessage(MESSAGE.Content.WorkOrder.Ref, MESSAGE)
-
-
If requestPath Is Nothing Then
-
returnMsg = ResponseMessage.getMessageType(
-
-
False, "logRequestMessage Failed.")
-
Util.logResponseMessage(MESSAGE.Content.WorkOrder.Ref, returnMsg)
-
-
-
Return returnMsg
-
-
End If
-
-
'validate the request message against svreq.xsd
-
-
Dim errorMessage As String = Util.validateRequestXML(requestPath)
-
-
If errorMessage = "" Then
-
-
'Util.errorLog("No errors in validation")
-
-
'if there is no error
-
-
If Util.ContainValidSenderAndRecipient(MESSAGE) Then
-
-
'if sender and recipient information are correct
-
-
'save the data into database.
-
-
'return success message-recipient
-
-
Dim db As New DataBase
-
db.insert_table_MESSAGE(MESSAGE)
-
-
-
If DataBase._errorMessage <> "" Then
-
returnMsg = ResponseMessage.getMessageType(
-
-
False, DataBase._errorMessage)
-
Util.logResponseMessage(MESSAGE.Content.WorkOrder.Ref, returnMsg)
-
-
-
Return returnMsg
-
-
End If
-
db.close()
-
-
returnMsg = ResponseMessage.getMessageType(
-
-
True, "")
-
Util.logResponseMessage(MESSAGE.Content.WorkOrder.Ref, returnMsg)
-
-
-
Return returnMsg
-
-
Else
-
-
'if not correct sender or recipient message
-
-
'create error log on server
-
-
'return failure message
-
Util.errorLog("Invalid Sender or Recipient")
-
-
returnMsg = ResponseMessage.getMessageType(
-
-
False, "Invalid Sender or Recipient")
-
Util.logResponseMessage(MESSAGE.Content.WorkOrder.Ref, returnMsg)
-
-
-
Return returnMsg
-
-
End If
-
-
Else
-
Util.errorLog("xmlValidation:" & errorMessage)
-
-
returnMsg = ResponseMessage.getMessageType(
-
-
False, errorMessage)
-
Util.logResponseMessage(MESSAGE.Content.WorkOrder.Ref, returnMsg)
-
-
-
Return returnMsg
-
-
End If
-
-
Catch ex As Exception
-
Util.errorLog("General: " & ex.Message & vbCrLf & ex.StackTrace)
-
-
returnMsg = ResponseMessage.getMessageType(
-
-
False, ex.Message)
-
Util.logResponseMessage(MESSAGE.Content.WorkOrder.Ref, returnMsg)
-
-
-
Return returnMsg
-
-
End Try
-
-
End Function
*************** ******
Now you could see one line which imports the db class (db.insert_tabl e_MESSAGE(MESSA GE)) this actually a general VB class and perform importing process of data using MESSAGE object which is XML file. It works fine, if messages sent one by one, but in case of concurrent session it generates the following error message.
"There is already an open DataReader associated with this Connection which must be closed first."
*************** *************** **********
This is the code in Database Class - Public Function insert_table_MESSAGE(ByVal obj_MESSAGE As WGS.wgsserver.MESSAGE) As Integer
-
-
-
If obj_MESSAGE Is Nothing Then
-
-
Return -1
-
-
End If
-
-
Dim databaseString As String
-
-
Dim reader As SqlDataReader
-
-
Try
-
-
Dim id_EnvelopeType As Integer = insert_table_EnvelopeType(obj_MESSAGE.Envelope)
-
-
Dim id_Content As Integer = insert_table_Content(obj_MESSAGE.Content)
-
databaseString = "insert into table_MESSAGE (col_Envelope, col_Content, col_MsgType, col_Version) values (" & id_EnvelopeType & ", " & id_Content & ", '" & FSSConversion(obj_MESSAGE.MsgType) & "', '" & FSSConversion(obj_MESSAGE.Version) & "')"
-
-
-
Dim command As New SqlCommand(databaseString)
-
command.Connection = conn
-
-
command.ExecuteNonQuery()
-
-
databaseString = "select id from table_MESSAGE where col_Envelope=" & id_EnvelopeType & " and col_Content=" & id_Content & " and col_MsgType='" & FSSConversion(obj_MESSAGE.MsgType) & "' and col_Version='" & FSSConversion(obj_MESSAGE.Version) & "'"
-
-
-
Dim command2 As New SqlCommand(databaseString)
-
command2.Connection = conn
-
-
reader = command2.ExecuteReader()
-
-
reader.Read()
-
-
-
Dim result As Integer = reader.GetInt32(0)
-
reader.Close()
-
-
-
Return result
-
-
Catch ex As Exception
-
_errorMessage = ex.Message
-
-
-
If Not reader Is Nothing Then
-
reader.Close()
-
-
-
End If
-
Util.errorLog("ERROR INSERT: " & ex.Message & vbCrLf & ex.StackTrace)
-
-
-
End Try
-
-
Return -1
-
-
End Function
*************** *************** ***************
I need your expert advice. I need to make that Web Service Working for Multiple Client concurrently.
Any help please...
Thanks in advance.
4 1786
Welcome to TheScripts TSDN...
Since the problem is related to ADO.Net I will move this thread to .Net forum.
Dorin.
One suggestion: check that the conn variable to not be defined as Shared (static).
Sorry about that.
I checked that and it is declared with in class as
"Private Shared conn As SqlConnection"
Is that going to be an issue?
Thanks for your help.
Just remove the Shared modifier, it should have no negative effect, since it's a private variable.
Then try few tests to make sure that it's working as desired.
Dorin.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dave O |
last post by:
Is it possible to return a SQLdatareader from a web
service?
|
by: Sean |
last post by:
Hello all,
I may just not be searching for the right thing, but I've been looking for a
way to dynamically create controls (and name them) in my code so that I can
create only the controls I need at run time. For example, I'm writing a
filewatcher service that will eventually write back to a database, but I may
need the service to watch multiple directories (thus, multiple
FileSystemWatcher components). The rub is this...how do I...
|
by: Andrei Pociu |
last post by:
In a typical ASP .NET Web Application (website), I'm currently using a class
where I declare some public static objects. For example there's the place
where I initialize the SqlConnection.
Also there's the place where I declare one public static DataReader, but I'm
not sure this is the best way to do it. I use that DataReader in all the
webforms and user controls, whenever I have to read data from the db.
So, should I do it this way or...
|
by: Sumaira Ahmad |
last post by:
Hi All
My Web Service is returning a DataSet. I realized that we cannot
return a DataReader.. Normally we can use a DataReader( when not
using Web services) and access it as below to assign values of columns
of returned rows to Labels in the client aplication such as:
while (dtrJobDetails.Read())
{
l_shortjobdesc.Text = dtrJobDetails.ToString();
|
by: Bihn |
last post by:
I was reading about datareader which is said to be slimmer & faster then
dataset. Since the datareader have to go fetching the dat from the database
every time it need it, the data it gets then should be up to date. However,
both the IbuySpy and Duwamish samples and most, if not all, the shopping
cart sample codes I've seen use dataset to implement the opration for
ecommerce sites. So is the trip that the datareader need to go fetch the...
| |
by: David Perona |
last post by:
Hi all,
I have a web service that connects to a SQL Server database and return
an sqlDataReader Object.
When launch the web service in the web browser, this exception is
thrown:
"Object Reference not established" from System.NullReferenceException.
If I change the web service to return a integer value, its run ok.
I'm Importing the System.Data.SqlClient namespace.
What's the problem?
|
by: Varangian |
last post by:
Hi all,
the question I want to ask if the conversion of a DataReader to a Table
looping through the DataReader is better than using the Fill Method of
the DataAdapter... I'm asking because internally the DataAdapter uses
the DataReader... so whats the deal of writing a method that converts a
DataReader into a DataTable ?
Thanks!
|
by: Diffident |
last post by:
Hello All,
I would like to use DataReader based accessing in my Data Access Layer
(DAL). What is considered to be a best practice while returning from a DAL
method that executes a query and returns N rows. DataReader object?
Collection object? DataTable object? Returning a DataReader object is not a
good practice...right?
Thnks for all your suggestions!!
|
by: TompIfe |
last post by:
Hi,
I have a web service that reads data from an Access database using
datareader and place the data in an array that
the web method returns.
Now, I want to make the web service also to return an xml file with the
data.
How do I best proceed?
Best regards,
Tom
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |