I need to return a dataset from wcf webservice .. i know that using a dataset in wcf web service will degrade the performance. But i cant go away with out using it!!!. Below is the method i am using in the webservice ..it works fine if the dataset is having
the data but if the dataset doesn't have rows i.e dataset is null then its throwing error in the client aspx page.. Is there any around for this solution like returning null dataset to the aspx page?..
[operation contract]
publicDataSet GetAccountDetails(int
Id, int UserId,
string CC)
Hi, you can check the dataset when you receive it in aspx page. When you call the wcf service, get the dataset and check for null. For example: - --------- DataSet ds = wcfObject.GetAccountDetails(1,1,"SomValue"); if (ds==null) {//Show appropriate message}
else {//bind it}
Please Mark As Answer if it helped.
MCPD ASP.NET 4.0 and 3.5, MCTS WSS, MOSS, SharePoint 2010, MCT
Microsoft Community Contributor Award 2011
Thanks for the reply.. Even though i am not able to get through the wcf web method. I am getting the below error while executing the method.
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
VISEServiceReference.VISEWCFServiceClient
dp1 = new VISEServiceReference.VISEWCFServiceClient();
I have done the modifications as u said like changing the
Dataset ds = new dataset();
but finally it throws an exception
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I make sure the web.config setting are fine and below is my configuration settings for the service
Thanks for the reply.. Even though i am not able to get through the wcf web method. I am getting the below error while executing the method.
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
VISEServiceReference.VISEWCFServiceClient
dp1 = new VISEServiceReference.VISEWCFServiceClient();
I have done the modifications as u said like changing the
Dataset ds = new dataset();
but finally it throws an exception
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I make sure the web.config setting are fine and below is my configuration settings for the service
You are right.. It works but for me in my situation i am using a stored proc and that stored proc i am using 10 tables with joins and getting the columns.. So please help me how to get the columns defined in that sproc..
Example:
In my webserice method i am using like this
In the below method sql command will the sproc name ...
SELECT cm.cust_xref_id,
cm = CASE WHEN @ScrambleAccount = 1 THEN scr_cm11 ELSE cm END,
LEFT('0' + CAST(cm2 AS varchar), 2) as cm2,
basic_cust_xref_id,
age_cd,
account_status_cd,
account_tenure,
product_cd = COALESCE(product_cd, ''),
product_type = COALESCE(fmly_ds, pm.product_type, ''),
plastic_desc = COALESCE(card_rollup_ds, pm.plastic_desc, ''),
bu.Name AS bu,
total_balance,
write_off_amt,
total_line,
rdmpts_mon_7_9,
rdmpts_mon_10_12,
mrearn_12monavg,
mrearn_sddev,
mrearn_mon_0_3,
mrearn_mon_4_6,
mrearn_mon_7_9,
mrearn_mon_10_12
FROM dbo.CardMaster cm
--JOIN dbo.CardCAS cas ON cas.cm11 = cm.cm
JOIN EnterpriseMIS.dbo.ProductMaster pm ON pm.ppt_cd = cm.product_cd
JOIN EnterpriseMIS.dbo.BUMaster bu ON bu.id = pm.BUId
WHERE cm = @cm11
AND cm2 = @cm2
ALTER PROCEDURE dbo.GetClassInfo
/*
(
@parameter1 int = 5,
@parameter2 datatype OUTPUT
)
*/
AS
/* SET NOCOUNT ON */
SELECT CLASS_ID+'00' AS CLASSID,CLASS_DESC FROM CLASSES JOIN Student ON CLASSES.CLASS_ID=Student.CLASS_NO
RETURN
You are right.. It works but for me in my situation i am using a stored proc and that stored proc i am using 10 tables with joins and getting the columns
it will return empty columns even if your using Storedprocedure,there is no difference using query or stored procedure.
Thanks
Regards,
Srinivas Ganaparthi,
'All things are difficult before they are easy'
My Blog
bboys
Member
12 Points
8 Posts
can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framework..
May 03, 2011 09:21 PM|LINK
I need to return a dataset from wcf webservice .. i know that using a dataset in wcf web service will degrade the performance. But i cant go away with out using it!!!. Below is the method i am using in the webservice ..it works fine if the dataset is having the data but if the dataset doesn't have rows i.e dataset is null then its throwing error in the client aspx page.. Is there any around for this solution like returning null dataset to the aspx page?..
[operation contract]
public DataSet GetAccountDetails(int Id, int UserId, string CC){
SqlCommand cmd;
DataSet ds = null;try
{
cmd =
new SqlCommand();cmd.CommandText =
"Get";cmd.Parameters.Add(
"@Id", SqlDbType.Int).Value = AppId;cmd.Parameters.Add(
"@UsrId", SqlDbType.Int).Value = UserId;cmd.Parameters.Add(
"@cc", SqlDbType.VarChar).Value = CC;ds = GetDataset(cmd);
}
catch (Exception ex){
LogManager.LogError(ex.Message + " Page :: " + strPage + " Method Name :: GetAccountDetails " + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf("line"), ex.StackTrace.Length - ex.StackTrace.LastIndexOf("line")), ex.GetHashCode(), HttpContext.Current.Application["ServerType"].ToString());
throw new Exception(ex.InnerException.ToString());}
return ds;}
adeelehsan
All-Star
18297 Points
2740 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 04, 2011 06:14 AM|LINK
MCPD ASP.NET 4.0 and 3.5, MCTS WSS, MOSS, SharePoint 2010, MCT
Microsoft Community Contributor Award 2011
ganaparthi
Participant
1266 Points
330 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 04, 2011 09:07 AM|LINK
instead of DataSet ds = null; use Dataset ds=new Dataset();
I have created method as follows
[OperationContract] public DataSet GetData() { DataSet ds = new DataSet(); return ds; }and i called like as follows
ServiceRef.Service1Client cleint = new ServiceRef.Service1Client(); DataSet ds=cleint.GetData();I didn't get any Error while accessing from client,its working fine.
thanks
Srinivas Ganaparthi,
'All things are difficult before they are easy'
My Blog
bboys
Member
12 Points
8 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 04, 2011 04:52 PM|LINK
Hi,
Thanks for the reply.. Even though i am not able to get through the wcf web method. I am getting the below error while executing the method.
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
VISEServiceReference.VISEWCFServiceClient dp1 = new VISEServiceReference.VISEWCFServiceClient();
ds = dp1.GetAccountDetails(Convert.ToInt16(Session["Id"]), userInfo.Id, cc);
I have done the modifications as u said like changing the
Dataset ds = new dataset();
but finally it throws an exception
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I make sure the web.config setting are fine and below is my configuration settings for the service
<
bindings
>
<
basicHttpBinding
>
<
binding name="BasicHttpBinding_VISEWCFService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
>
<
readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<
security mode="Transport"><
transport clientCredentialType="Windows" proxyCredentialType="None" realm=""
/>
<
message clientCredentialType="UserName" algorithmSuite="Default"
/>
</
security>
</
binding><
binding name="BasicHttpBinding_VISEWCFService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<
readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/><
security mode="TransportCredentialOnly"
>
<
transport clientCredentialType="Windows" proxyCredentialType="None" realm=""
/>
<
message clientCredentialType="UserName" algorithmSuite="Default"
/>
</
security
>
</
binding
>
</
basicHttpBinding
>
<
customBinding
>
<
binding name="customBinding0">
<
binaryMessageEncoding/><
httpsTransport/></
binding
>
</
customBinding
>
</
bindings
>
bboys
Member
12 Points
8 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 04, 2011 04:54 PM|LINK
Hi,
Thanks for the reply.. Even though i am not able to get through the wcf web method. I am getting the below error while executing the method.
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
VISEServiceReference.VISEWCFServiceClient dp1 = new VISEServiceReference.VISEWCFServiceClient();
ds = dp1.GetAccountDetails(Convert.ToInt16(Session["Id"]), userInfo.Id, cc);
I have done the modifications as u said like changing the
Dataset ds = new dataset();
but finally it throws an exception
The request channel timed out while waiting for a reply after 00:10:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I make sure the web.config setting are fine and below is my configuration settings for the service
<
bindings
>
<
basicHttpBinding
>
<
binding name="BasicHttpBinding_VISEWCFService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
>
<
readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<
security mode="Transport"><
transport clientCredentialType="Windows" proxyCredentialType="None" realm=""
/>
<
message clientCredentialType="UserName" algorithmSuite="Default"
/>
</
security>
</
binding><
binding name="BasicHttpBinding_VISEWCFService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<
readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/><
security mode="TransportCredentialOnly"
>
<
transport clientCredentialType="Windows" proxyCredentialType="None" realm=""
/>
<
message clientCredentialType="UserName" algorithmSuite="Default"
/>
</
security
>
</
binding
>
</
basicHttpBinding
>
<
customBinding
>
<
binding name="customBinding0">
<
binaryMessageEncoding/><
httpsTransport/></
binding
>
</
customBinding
>
</
bindings
>
bboys
Member
12 Points
8 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 04, 2011 05:13 PM|LINK
Hi All,
I am able to return a empty dataset(no rows and no columns). But what i need is a dataset with no rows with columns).
For exmple select empid,empname from tblemp returns no rows... this is what i need to return
In the previous replies if i use
Dataset ds = new Dataset(); then i will get the empty dataset...
but in my scenario only the rows will be empty but the column names will be there ....
ganaparthi
Participant
1266 Points
330 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 06, 2011 09:43 AM|LINK
Hi,
write your method as follows if you have no rows in your database it will automatically returns all columns with zero rows
SqlConnection cn = new SqlConnection("Data Source=.;database=NorthWind;user id=sa;password=sa@123"); [OperationContract] public DataSet GetData() { DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("select * from Emp", cn); da.Fill(ds, "Emp"); return ds; }and calling from client as follows
ServiceRef.Service1Client cleint = new ServiceRef.Service1Client(); DataSet ds = cleint.GetData();Hope it will solve your problem.
Please mark as answer if post is solved your problem
Thanks
Srinivas Ganaparthi,
'All things are difficult before they are easy'
My Blog
bboys
Member
12 Points
8 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 06, 2011 05:47 PM|LINK
Hi Ganpathi,
You are right.. It works but for me in my situation i am using a stored proc and that stored proc i am using 10 tables with joins and getting the columns.. So please help me how to get the columns defined in that sproc..
Example:
In my webserice method i am using like this
In the below method sql command will the sproc name ...
public DataSet GetDataset(SqlCommand Command){
DataSet ds = new DataSet();
SqlDataAdapter da = null;try
{
OpenDatabase();
Command.Connection = _dbConnection;
Command.CommandTimeout = 1200;
Command.CommandType =
CommandType.StoredProcedure;da =
new SqlDataAdapter(Command);da.Fill(ds);
}
catch (Exception ex){
LogManager.LogError(ex.Message + " Page :: " + strPage + " Method Name :: GetDataset " + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf("line"), ex.StackTrace.Length - ex.StackTrace.LastIndexOf("line")), ex.GetHashCode(), HttpContext.Current.Application["ServerType"].ToString());
throw new Exception("Error executing procedure", ex.InnerException);}
return ds;}
SELECT cm.cust_xref_id,
cm = CASE WHEN @ScrambleAccount = 1 THEN scr_cm11 ELSE cm END,
LEFT('0' + CAST(cm2 AS varchar), 2) as cm2,
basic_cust_xref_id,
age_cd,
account_status_cd,
account_tenure,
product_cd = COALESCE(product_cd, ''),
product_type = COALESCE(fmly_ds, pm.product_type, ''),
plastic_desc = COALESCE(card_rollup_ds, pm.plastic_desc, ''),
bu.Name AS bu,
total_balance,
write_off_amt,
total_line,
rdmpts_mon_7_9,
rdmpts_mon_10_12,
mrearn_12monavg,
mrearn_sddev,
mrearn_mon_0_3,
mrearn_mon_4_6,
mrearn_mon_7_9,
mrearn_mon_10_12
FROM dbo.CardMaster cm
--JOIN dbo.CardCAS cas ON cas.cm11 = cm.cm
JOIN EnterpriseMIS.dbo.ProductMaster pm ON pm.ppt_cd = cm.product_cd
JOIN EnterpriseMIS.dbo.BUMaster bu ON bu.id = pm.BUId
WHERE cm = @cm11
AND cm2 = @cm2
Peter pi - M...
Star
12871 Points
1786 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 09, 2011 03:26 AM|LINK
Hi bboys,
Stored procedure can also get the columns.
For example:
SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=WEBDB;Integrated Security=True"); conn.Open(); SqlDataAdapter dataadapter = new SqlDataAdapter("GetClassInfo", conn); dataadapter.SelectCommand.CommandType = CommandType.StoredProcedure; DataSet dataset = new DataSet(); try { dataadapter.Fill(dataset); DataTable dt = dataset.Tables[0]; } catch (Exception ex) { throw ex; } finally { conn.Close(); }Store procedure:
Best regards,
Peter
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
ganaparthi
Participant
1266 Points
330 Posts
Re: can i return null object (dataset) from a WCF webservice to the apsx page in .net 3.5 framewo...
May 09, 2011 05:25 AM|LINK
Hi bboys,
it will return empty columns even if your using Storedprocedure,there is no difference using query or stored procedure.
Thanks
Srinivas Ganaparthi,
'All things are difficult before they are easy'
My Blog