Reputation: 1640
I'm a newbie to WCF technology. My current problem is that my windows forms app isn't getting a respond from wcf program. Here is the code for my windows forms app :
WCFService.PMSService obj = new WCFService.PMSService();
string xx = obj.Test("Hello");
MessageBox.Show(xx);
My windows forms app hangs on this line -> string xx = obj.Test("Hello");
Here is the code for wcf my program :
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IPMSService
{
[OperationContract]
string DetermineGender(PersonalInfo pInfo);
[OperationContract]
string Test(string val);
}
[DataContract]
public enum Gender
{
[EnumMember]
Male,
[EnumMember]
Female,
[EnumMember]
None
}
// Use a data contract as illustrated in the sample below to add composite types to service operations
[DataContract]
public class PersonalInfo
{
[DataMember]
public string name
{
get { return name; }
set { name = value; }
}
[DataMember]
public string surname
{
get { return surname; }
set { surname = value; }
}
[DataMember]
public string idNo
{
get { return idNo; }
set { idNo = value; }
}
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class PMSService : IPMSService
{
public string DetermineGender(PersonalInfo pInfo)
{
Gender Result = Gender.None;
int idNo = Convert.ToInt32(pInfo.idNo.Substring(6, 4));
if (idNo >= 5000)
Result = Gender.Male;
else
Result = Gender.Female;
return Result.ToString();
}
public string Test(string val)
{
return "U passed " + val;
}
}
Does anybody know the possible cause ?
Upvotes: 0
Views: 443
Reputation: 7067
The best suggestion (and perhaps so obvious that many overlook) for someone new to WCF is to become familiar with WCF Tracing and Message Logging. The WCF tracing functionality provides a relatively simple, built-in method to monitor communication to/from WCF services. For test and debugging environments, configure informational or verbose activity tracing and enable message logging. The combination of activity tracing and message logging should prove beneficial when initially deploying and testing new services or adding new operations and/or communication bindings to existing services.
The following links provide a good overview:
http://msdn.microsoft.com/en-us/library/ms733025.aspx
http://msdn.microsoft.com/en-us/library/aa702726.aspx
Upvotes: 1