Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am getting a really annoying newbie problem.

I am utilizing an N-tier architecture. I have a DataEntity layer and a DataAccess tier and then a WCF service sandwiched in between the data entity layer and the ASP.NET Web Site-based Presentation layer.

I went ahead and added a Service Reference to my WCF service and then I did the following ASP:

ASP
<form id="form1"  runat="server">
<div>
    <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1"
        AutoGenerateColumns="False" >
        <columns>
            <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True"
                SortExpression="Name" />
            <asp:BoundField DataField="email" HeaderText="email" ReadOnly="True"
                SortExpression="email" />
            <asp:BoundField DataField="phone" HeaderText="phone" ReadOnly="True"
                SortExpression="phone" />
            <asp:BoundField DataField="Zip" HeaderText="Zip" ReadOnly="True"
                SortExpression="Zip" />
            <asp:BoundField DataField="PropertyType" HeaderText="PropertyType"
                SortExpression="PropertyType" />
            <asp:BoundField DataField="Message" HeaderText="Message" ReadOnly="True"
                SortExpression="Message" />
            <asp:BoundField DataField="EntryDate" HeaderText="EntryDate"
                SortExpression="EntryDate" />
            <asp:BoundField DataField="URL" HeaderText="URL" ReadOnly="True"
                SortExpression="URL" />
            <asp:BoundField DataField="Form" HeaderText="Form" ReadOnly="True"
                SortExpression="Form" />
            <asp:BoundField DataField="CustomerNumber" HeaderText="CustomerNumber"
                SortExpression="CustomerNumber" />
            <asp:BoundField DataField="ContactType" HeaderText="ContactType"
                SortExpression="ContactType" />
        </columns>

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        SelectMethod="GetConsultationRequestContacts"
        TypeName="DataServiceReference.DataServiceClient" />

</div>
</form>


I think I'm doing it right, however I keep getting:

The communication object, System.ServiceModel.ChannelFactory`1[DataServiceReference.IDataService], cannot be used for communication because it is in the Faulted state.

I admit, I am a newbie. Is there more code I need to add?

Brian
Posted
Updated 11-Apr-11 7:29am
v3

I think the problem is with specifying
TypeName="DataServiceReference.DataServiceClient". Specify it as Your ProjectName.DataServiceReference as DataServiceClient is the class created by WCF automatically for you to handle all low level calls.
 
Share this answer
 
I also found that you'll want to set up a connection to the adapter as follows:

C#
using System;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
    DataServiceReference.AbstractsClient _abstractsClient = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (_abstractsClient == null)
        {
            _abstractsClient = new DataServiceReference.AbstractsClient();
            _abstractsClient.Open();
        }
    }
    protected void AbstractsDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
    {
        // set the object instance
        if (_abstractsClient.State == System.ServiceModel.CommunicationState.Opened)
            e.ObjectInstance = _abstractsClient;
    }
    protected void AbstractsDataSource_ObjectDisposing(object sender, ObjectDataSourceDisposingEventArgs e)
    {
        // set this so the object is not disposed afterwards
        e.Cancel = true;
    }
    protected void AbstractsDataSource_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900