I am trying to call a method located in a remote wcf service using Channel Factory. It is the first time for me to use channel factory, but it returns non-correct values of the properties of the object. Below I will present the code:
IVrindassDigitalService.cs:
public interface IVrindassDigitalService
{
Vrindassinfo GetVrindassStatusAndDate();
}
VrindassDigitalService.cs:
public class VrindassDigitalService: IVrindassDigitalService
{
public Vrindassinfo GetVrindassStatusAndDate()
{
BasicHttpBinding myBinding = new BasicHttpBinding();
Vrindassinfo result = new Vrindassinfo();
try
{
EndpointAddress myEndpoint = new EndpointAddress(“http://svc-server/OnlineDataStore.svc”);
ChannelFactory<IVrindassDigitalChannel> myChannelFactory =
new ChannelFactory<IVrindassDigitalChannel>(myBinding, myEndpoint);
// Create a channel
IVrindassDigitalChannel wcfClient = myChannelFactory.CreateChannel();
result = wcfClient.GetVrindassStatusAndDate();
}
catch (Exception ex)
{
}
return result;
}
}
Vrindassinfo class:
public partial class Vrindassinfo
{
public System.DateTime VrindassDate { get; set; }
public System.DateTime VrindassDateTime { get; set; }
public bool isActive { get; set; }
}
WSDL Snippets:
<wsdl:portType name="Utility">
<wsdl:operation name="GetVrindassStatusAndDate">
<wsdl:input wsaw:Action="http://tempuri.org/Utility/GetVrindassStatusAndDate" message="tns:Utility_GetVrindassStatusAndDate_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/Utility/GetVrindassStatusAndDateResponse" message="tns:Utility_GetVrindassStatusAndDate_OutputMessage"/>
</wsdl:operation>
…..
<wsdl:binding name="BasicHttpBinding_Utility" type="tns:Utility">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetVrindassStatusAndDate">
<soap:operation soapAction="http://tempuri.org/Utility/GetVrindassStatusAndDate" style="document"/>
………….
Call method:
//get Vrindass date
Vrindassinfo VrindassInfo = _VrindassDigitalService.GetVrindassStatusAndDate();
The problem is that the values of the fields (VrindassDate and VrindassDateTime) of the Vrindassinfo object come as 01/01/0001, which are not the real values that should be returned by the web service.The web service must return the current date. I have been trying to solve it as a problem for several hours, but I don't know where exactly the problem is. Thank you