I'm having issues passing POCO as input parameter in a WCF service. To simplify, i've tested this with the "out of the box" item generated code and have the same issue.
When you create a wcf service the generated files are
Iservice1.cs
namespace WcfServiceLibrary2
{
// 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 IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
}
and Servce1.cs.Text;
namespace WcfServiceLibrary2
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}
}
When I "Add Service Reference" and use default settings, then attempt to call method in client:
CompositeType ct = new CompositeType();
svc.GetDataUsingDataContract(ct);
I get
"The best overloaded method match for
WpfMvvmApplication1.ServiceReference1.Service1Client.GetDataUsingDataContract(WpfMvvmApplication1.ServiceReference1.CompositeType)' has some invalid arguments "
The service reference changes the explicitly declared delegate of the GetDataUsingDataContract() method from
GetDataUsingDataContract(WpfMvvmApplication1.ServiceReference1.CompositeType param) to
GetDataUsingDataContract(WpfMvvmApplication1.ServiceReference1.Service1Client.CompositeType param)
and you cannot cast / convert one to the other. Any ideas.