C# 如何在WindowsPhone7应用程序中使用wcf服务?

C# 如何在WindowsPhone7应用程序中使用wcf服务?,c#,wcf,windows-phone-7,wcf-binding,wcf-security,C#,Wcf,Windows Phone 7,Wcf Binding,Wcf Security,我在服务器端使用过这个代码 [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "/UploadData?Name={Name}&Email={Email}&ContactNumber={ContactNumber}&DeviceModel={DeviceModel}&Problem={Problem}&Besttimetocontact={Bestti

我在服务器端使用过这个代码

[OperationContract]        
        [WebInvoke(Method = "POST", UriTemplate = "/UploadData?Name={Name}&Email={Email}&ContactNumber={ContactNumber}&DeviceModel={DeviceModel}&Problem={Problem}&Besttimetocontact={Besttimetocontact}",        
            BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)]
        NewClsMessage UploadData(string Name, string Email, string ContactNumber, string DeviceModel, string Problem, string Besttimetocontact);

 public NewClsMessage UploadData(string Name, string Email, string ContactNumber, string DeviceModel, string Problem, string Besttimetocontact)
{
            NewClsMessage ObjNewClsMessage = new NewClsMessage();
            try
            {
  str_value = "insert into Estimate(Name,Email,ContactNumber,DeviceModel,Problem,Besttimetocontact) values('" + Name + "','" + Email + "','" + ContactNumber + "','" + DeviceModel + "','" + Problem + "', '" + Besttimetocontact + "')";                 

                OpenConnection();
                sqlCmd.CommandType = CommandType.Text;
                sqlCmd.CommandText = str_value;
                value = sqlCmd.ExecuteNonQuery();
                if (value > 0)
                {
                    ObjNewClsMessage = new NewClsMessage();
                    ObjNewClsMessage.Result = "1";
                    ObjNewClsMessage.Message = "send Successfully";
                }
                else
                {
                    ObjNewClsMessage = new NewClsMessage();
                    ObjNewClsMessage.Result = "0";
                    ObjNewClsMessage.Message = "Free Estimate not send Successfully";
                }
}

 catch (Exception ex)
            {
            }
            return ObjNewClsMessage;
客户端代码是

WebClient webClient = new WebClient();
            webClient.Headers[HttpRequestHeader.ContentType] = "application/xml";
            //  var uri = new Uri("localhost:55666/WcfPostMethod/Service.svc/UploadXml");
            var uri = new Uri("http://localhost:50546/Service1.svc/UploadData");
            StringBuilder postData = new StringBuilder();
            postData.AppendFormat("?{0}={1}", "Name", HttpUtility.UrlEncode("hi"));
            postData.AppendFormat("&{0}={1}", "Email", HttpUtility.UrlEncode("hi@gmail.com"));
            postData.AppendFormat("&{0}={1}", "ContactNumber", HttpUtility.UrlEncode("56898"));
            postData.AppendFormat("&{0}={1}", "DeviceModel", HttpUtility.UrlEncode("E4376"));
            postData.AppendFormat("&{0}={1}", "Problem", HttpUtility.UrlEncode("Repair"));
            postData.AppendFormat("&{0}={1}", "Besttimetocontact", HttpUtility.UrlEncode("9am"));            
            webClient.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
            webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(webClient_UploadStringCompleted);
            webClient.UploadStringAsync(uri, "POST", postData.ToString());

在这里,我在服务器端得到了一个错误。在客户端应用程序中发布数据意味着,在服务器端,数据会得到空(null)值。如何解决这个问题?

您能告诉我们您的wcf服务在没有客户端的情况下是否可以工作吗

这是一个很好的工具(Storm或WCF Storm)

您甚至可以找到一个示例: