2011-08-19 166 views
1

當我嘗試連接到我的WCFService時發生以下錯誤。WCF「內容類型不支持」錯誤

內容類型text/xml; charset = utf-8不支持服務 http://localhost:1978/Service1.svc。客戶端和服務綁定 可能不匹配。

我的服務代碼是:

namespace WcfService1 
{ 
    [ServiceContract] 
    public interface IService1 
    { 
     [OperationContract] 
     string GetData(string fName, string lName); 
    } 
} 

並在客戶端的形式,我如下調用這個服務:

endPointAddr = "http://localhost:1978/Service1.svc"; 

BasicHttpBinding httpBinding = new BasicHttpBinding(); 
httpBinding.TransferMode = TransferMode.Buffered; 

EndpointAddress endpointAddress = new EndpointAddress(endPointAddr); 

Append("Attempt to connect to: " + endPointAddr); 

IService1 proxy = ChannelFactory<IService1>.CreateChannel(httpBinding, endpointAddress); 

using (proxy as IDisposable) 
{ 
    string strNew=proxy.GetData(textBox2.Text, textBox1.Text) ; 
} 

我被困在這個錯誤,如果有人知道,請幫助。

+1

什麼是您的服務的配置? – Tim

回答

2

我懷疑你的WCF服務具有約束力的WSHttpBinding或類似的 - 你需要改變客戶端綁定(這是目前使用BasicHttpBinding)據此,使其工作...

相關問題