I am new to the WCF and facing some little problem. Initially, I just used the WCF service template for the test service. There are two default OperationContract as below:
After adding these methods I have implemented it like bleow:
public Product GetDataUsingProductContract(int Id)
{
Product P = new Product();
P.ProductId = Id;
P.PName = "Here is the product";
return P;
}
and follow the simple steps to update the reference file:
1) Rebuild the service application
2) Update the service refrence file in the client application
But after follow these steps, the new method "GetDataUsingProductContract" is not exposing at the client side. This method will only exposed when I delete the proxy file (generateproxy.cs) and add again using the SVCUtil.exe. I think there should be some
technique to update the service references file without recreating it.
I am using visual studio 2010 and it is also do not work in 2008.
My client side code is :
namespace ClientApplication
{
class Program
{
static void Main(string[] args)
{
Service1Client S = new Service1Client();
Console.WriteLine(S.GetData(1));
Add a service reference in your client application by right-clicking the project and choose "Add Service Reference". You will then be able to update the service reference by right-clicking on it and choose "Update Service reference".
If you are creating a proxy class through the svcutil utility you need to re-generate the proxy class each time your service is modified.
and the updating operation is also relying on the metadata document of the WCF service. Therefore, you can use webbrowser to view the metadata document(WSDL) of your WCF service after you made any changes. If the metadata document does contains the new added
operation defintions, then the service definition is updated and the client should be able to regenerate the proxy based on the new metadata.
Jibi
0 Points
19 Posts
Service References are not updating in the data contracts
Mar 31, 2012 11:59 AM|LINK
Hi,
I am new to the WCF and facing some little problem. Initially, I just used the WCF service template for the test service. There are two default OperationContract as below:
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
Initially both are also exposing at the client side in the intellicense and I can consume these services. But as I added a new contract like below:
[OperationContract]
Product GetDataUsingProductContract(int id);
For this class in the same assembly
[DataContract]
public class Product
{
[DataMember]
public int ProductId
{
get;
set;
}
[DataMember]
public string PName
{
get;
set;
}
}
After adding these methods I have implemented it like bleow:
public Product GetDataUsingProductContract(int Id)
{
Product P = new Product();
P.ProductId = Id;
P.PName = "Here is the product";
return P;
}
and follow the simple steps to update the reference file:
1) Rebuild the service application
2) Update the service refrence file in the client application
But after follow these steps, the new method "GetDataUsingProductContract" is not exposing at the client side. This method will only exposed when I delete the proxy file (generateproxy.cs) and add again using the SVCUtil.exe. I think there should be some technique to update the service references file without recreating it.
I am using visual studio 2010 and it is also do not work in 2008.
My client side code is :
namespace ClientApplication
{
class Program
{
static void Main(string[] args)
{
Service1Client S = new Service1Client();
Console.WriteLine(S.GetData(1));
Console.Read();
}
}
}
Thanks in advance !
mm10
Contributor
6409 Points
1184 Posts
Re: Service References are not updating in the data contracts
Apr 01, 2012 02:37 PM|LINK
Add a service reference in your client application by right-clicking the project and choose "Add Service Reference". You will then be able to update the service reference by right-clicking on it and choose "Update Service reference".
If you are creating a proxy class through the svcutil utility you need to re-generate the proxy class each time your service is modified.
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: Service References are not updating in the data contracts
Apr 02, 2012 03:55 AM|LINK
Hi Jibi,
As mm10 suggested, you can right click the existing "service reference" in Visual Studio IDE and use "Update Service Reference" to update it.
#How to: Add, Update, or Remove a Service Reference
http://msdn.microsoft.com/en-us/library/bb628652.aspx
and the updating operation is also relying on the metadata document of the WCF service. Therefore, you can use webbrowser to view the metadata document(WSDL) of your WCF service after you made any changes. If the metadata document does contains the new added operation defintions, then the service definition is updated and the client should be able to regenerate the proxy based on the new metadata.
Feedback to us
Microsoft One Code Framework