Search code examples
.netwcfweb-servicesserializationdatacontract

help invoking wcf service


I am trying my hands on creating and consuming wcf services. when i try to call a service operation that expects a data contract as a request, it gives me a compile time error. It says that data contract can't be converted in to string. I thing, I have to serialize it first. But I don't know how to do serialization or deserialization.

 public partial class _Default : System.Web.UI.Page
    {
        Service1Client _client = new Service1Client();

        protected void Page_Load(object sender, EventArgs e)
        {

            CompositeType _dataContract = new CompositeType();
            _dataContract.BoolValue = false;
            _dataContract.StringValue = "vaibhav";

            TextBox1.Text=_client.GetDataUsingDataContract(_dataContract);

        }
    }

Solution

  • That last line should be something like:

     _dataContract = _client.GetDataUsingDataContract(_dataContract);
     TextBox1.Text = dataContract.StringValue; 
    

    If that doesn't work, post the exact error message and line number.