2012-06-25 38 views
0

我正在構建一個WCF服務,我已將合同寫入IService文件並在服務文件中實現它,當我嘗試更改任何返回值時出現問題我已聲明的方法的值,這是因爲它們被保存在CustomersService名稱空間中的代碼中,特別是鎖定在CustomersServiceClient類中,並且無法訪問以進行更改。無法更改wcf合同的方法返回值

這是我在ICustomersService文件中的代碼:

[ServiceContract] 
    public interface ICustomersService 
    { 
     [OperationContract] 
     CustomerDetails GetCustomerDetails(string customerid); 
     [OperationContract] 
     bool VerifyId(string customerid); 
    } 

,並在CustomersService文件中的代碼:

public CustomerDetails GetCustomerDetails(string customerid) 
{ 
.... 
} 
public bool VerifyId(string customerid) 
{ 
... 
} 

,並在CustomerService1命名空間我都已經生成驗證碼並鎖定,所以任何試圖修改我在IService中的方法都是令人失望的,因爲它在這裏被鎖定,無法更改!

public class CustomersServiceClient : ClientBase<ICustomersService>, ICustomersService 
    { 
     public CustomersServiceClient(); 
     public CustomersServiceClient(string endpointConfigurationName); 
     public CustomersServiceClient(Binding binding, EndpointAddress remoteAddress); 
     public CustomersServiceClient(string endpointConfigurationName, EndpointAddress remoteAddress); 
     public CustomersServiceClient(string endpointConfigurationName, string remoteAddress); 

     public CustomerDetails GetCustomerDetails(string customerid); 
     public bool VerifyId(string customerid); 
    } 

這對我來說是嚴重的問題我希望你找到我一些答案。

+2

請張貼一些代碼,顯示您現在擁有什麼以及想要完成什麼 - 很難理解您想要做什麼。 – carlosfigueira

+0

當然,我會,謝謝你的注意。 –

回答

1

Web服務比引用程序集稍微複雜一些。如果您更改服務界面,代理類代碼不會自動更新。每次更改合同時都需要手動更新它。

試試這個:

  1. 客戶項目 - >服務引用
  2. 選擇您的參考 - >右鍵點擊鼠標
  3. 更新服務參考

WCF還可以,如果重用你的合同類型你引用該程序集。在這種情況下,數據合同的更改將立即在客戶端看到。您可能會在該答案中找到實施步驟: How to use a custom type object at the client

+0

非常有幫助,謝謝! –