So my question is much like this one: WCF service: Returning custom objects, however, despite the solutions in that question I see nothing working.
Yesterday I proposed a question related to this one, but I've come closer, if not identified the potential source of my issue.
I don't believe it is problem with the size of the data that I am working with. I can send this data to the server, but I am having a problem with retrieving it. I'm returning an object called ProjectDetails
over WCF
. However, I run into an issue with receiving it from the service to the client.
Is there a setting that I am missing or is there a way I configured my class for WCF
incorrectly?
Here is my ProjectDetails
code:
[DataContract]
public class ProjectDetails
{
[DataMember]
public int projectId { get; set; }
[DataMember]
public string name { get; set; }
[DataMember]
public int calYearId { get; set; }
[DataMember]
public string projectState { get; set; }
[DataMember]
public string reportTitle { get; set; }
[DataMember]
public int plantId { get; set; }
[DataMember]
public string holdNumber { get; set; }
[DataMember]
public string holdDescription { get; set; }
[DataMember]
public string remarks { get; set; }
[DataMember]
public string adminComments {get; set; }
[DataMember]
public int companyId { get; set; }
[DataMember]
public int customerId { get; set; }
[DataMember]
public string folderNumber { get; set; }
[DataMember]
public int invoicedInFull { get; set; }
[DataMember]
public int approved { get; set; }
}
Here is how the it is defined in my Service Contract:
[ServiceContract]
public interface IProjectService
{
[OperationContract]
ProjectDetails GetProjectDetails(int selected_id);
}
I have regenerated my proxy with svcutil.exe
and updated my service reference. However, every time I call the GetProjectDetails
method my code fails. I get:
The underlying connection was closed: An unexpected error occurred on a receive.
Please, if anyone can help, I would be so grateful.
Update
Client side config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IProjectService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.0.99:9000/ProjectService/ProjectService"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProjectService"
contract="IProjectService" name="BasicHttpBinding_IProjectService" />
</client>
</system.serviceModel>
</configuration>
Client side config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="ProjectBaseWCFServiceLib.Service1Behavior" name="ProjectBaseWCFServiceLib.ProjectService">
<endpoint address="" binding="basicHttpBinding" contract="ProjectBaseWCFServiceLib.IProjectService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/ProjectBaseWCFServiceLib/Service1/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ProjectBaseWCFServiceLib.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Client side code:
Console.WriteLine("Testing................");
ProjectBaseWCFServiceLib.ProjectDetails details = client.GetProjectDetails(1);
Console.WriteLine(details.adminComments);
Console.WriteLine(details.approved);
Console.WriteLine(details.calYearId);
Console.WriteLine(details.companyId);
Console.WriteLine(details.folderNumber);
Console.WriteLine(details.holdDescription);
Console.WriteLine(details.holdNumber);
Console.WriteLine(details.invoicedInFull);
Console.WriteLine(details.name);
Console.WriteLine(details.plantId);
Console.WriteLine(details.projectId);
Console.WriteLine(details.projectState);
Console.WriteLine(details.remarks);
Console.WriteLine(details.reportTitle);