DataContract create in WCF

At client side, I have this class without [DataContract]:

public class UserEntity { public string login; public string password; }

when I put [DataContract] and refresh the reference of this class at WCF side, then I can't initiate the web service. It says an error:

cannot create metadata...

What's wrong?

-------------Problems Reply------------

Are you sure that you actually know, why you can't refresh the reference? I mean you add [DataMember] - and it fails, you remove it - it works? Or it works several days ago and now you add [DataMember] (and many other stuff) and it not works now?

But anyway, the easiest way to solve "refresh reference" issues - to refresh reference manually with SvcUtil.exe. In this case error message would be much more descriptive the simple "oops! error!".

What is client and server side in your case? What is refreshing reference on the WCF side? Your description is very uncommon. Here is description how to create service with complex data type and WCF Class library:

  • Create WCF class library
  • Add data contract to the class library
  • Add service to class library
  • Implement service contract and service in the class library
  • Add host project
  • Reference WCF class library from host project
  • Host service from class library in host project
  • Add Metadata endpoint to your hosted service
  • Create client project
  • Run the host project outside the visual studio
  • Use Add service reference to create proxy on WCF service hosted in your host project
  • Implment code to call your service through created proxy

As you see there is no modification of data contract on the client side and no refreshing WCF service.

Category:c# Views:1 Time:2010-08-20

Related post

  • What DataContract object types to avoid when creating a WCF service? 2012-02-24

    I would like to know all the types i should avoid when i am creating my WCF DataContract. I would like my Service to be completely compatible with any Client platform. This is my interface: public interface IShopriteService { [OperationContract] Chan

  • How to use a WSDL File to create a WCF Proxy? 2009-06-03

    I have an old WSDL file and I want to use WCF to communicate with the service. The WSDL is generated from a ASMX (I suppose but I am not sure). What would be the required steps to communicate with it ? --------------Solutions------------- Use svcutil

  • Error creating a WCF endpoint 2009-08-18

    Why do I need to include a DnsEndpointIdentity when creating my WCF endpoints? So when I create an endPoint like this: EndpointAddress endpoint = new EndpointAddress(uri); I get a SSPI authentication failed error But when I do this it works just fine

  • Creating a WCF ServiceHost object takes three to four minutes on some PCs 2009-10-16

    I have created a WCF service which does not use the app.config to configure itself. However, it takes three to four minutes on some PCs to construct the ServiceHost object. Thinking there was something wrong with my service, I constructed a simple He

  • Exception in creating a WCF Service using MsmqIntegrationBinding 2009-12-23

    My machine is Windows 7 ultimate (64 bit). I have installed MSMQ and checked that it is working fine (ran some sample codes for MSMQ). When i try to create a WCF Service using MsmqIntegrationBinding class, i get the below exception: "An error occurre

  • Can I create a WCF workflow using the standard Workflow activity templates? 2010-07-21

    Is it possible to create a WCF workflow using the standard (Activity template) Workflow activity templates? And, if so, where can I find some samples that DO NOT use the standard WCF service template (WCF Workflow Service template)? Explanation: I'm

  • How to create a WCF reply service for AJAX unit testing 2010-09-04

    I want to create a WCF service that will simply reply back the query string, HTTP headers, and the HTTP verb used in a request it received. I want to use it to unittest a AJAX enabled JavaScript framework I am building so I can verify that the HTTP h

  • Creating a WCF service to a MVC webapplication 2010-09-13

    I wonder if there are some differences between creating a WCF service and an MVC web-application. If you know of good links on how to create such a service for an MVC application that returns a JSON object please do post them. --------------Solutions

  • How to create a WCF service 2010-11-30

    I want to learn step by step how to create a WCF service, starting from something very simple. Can anyone help me? --------------Solutions------------- See this series of web casts by Michelle Bustamonte. If you are a beginner, this is one of the bes

  • WCF Newbie: Create a WCF Proxy to connect to old ASMX Web Service 2011-02-15

    I am currently assigned on a task where I need to create a WCF that will act as a proxy to 3 ASMX services. Currently these services are consumed directly by several applications. Reason for building this WCF proxy is that it would be easier for us t

  • Create operation wcf with parameters matching databas fields 2011-02-27

    I want to consume a wcf service in a php script and the goal is to insert a record into a database. My database table has 4 fields..is it possible to create a wcf service that will accept 4 parameters, one for each field? I guess this is similar to a

  • WCF: Create public WCF service to response data in JSON: Simple Example 2011-05-11

    As I am working on one web application, I want to create one WCF service to expose our system data. My service will receive input data(params) and based on that, I want to response data using JSON format to our customer/caller. I also wants to create

  • Creating a WCF service using http 2011-06-23

    I'm trying to simulate an existing API and I would love to get some help. How can I create a WCF service that will respond to: http://www.something.com/dothis?param1=x&param2=y And will run the function dothis with the given parameters' values. A

  • How to create a WCF client, that will update service reference programmatically? 2011-10-15

    I don't exactly know, how to ask this question. I have 3 computers in my local network. On first computer I have installed windows service which hosts WCF Services (binding netTcp). So my address is "net.tcp://localhost:8523/Sms" for example. Now, I

  • How to Create a WCF Service with 100% Availability Even Upon Update? 2011-11-25

    I need to create a service that will expose data and contain business logic that different clients will use. The problem is that if I develop it as a single WCF service I will need to shutdown it for some time to update it. This is not acceptable. I

  • Is there a way to create a WCF DataContract on a third party type? 2010-04-12

    I am migrating to wcf and trying to figure out how I'm going to declare my Data Contracts properly. Some of the types I have been remoting are from a third party that I am unable to change. Are attributes the only way to explicitly declare data contr

  • How to parse JSON created by WCF DataContract object 2011-05-18

    I have an object decorated with [DataContract] attribute and my WCF service is returning this as JSON like this: {"GetCommentsByPostResult":[{"CommentCreated":"\/Date(1305736030505+0100)\/","CommentText":"Comment 1"},{"CommentCreated":"\/Date(1305736

  • Injecting an unrelated contract into the WSDL created by WCF's MEX provider 2009-05-14

    I am implementing a WCF service (Contract A) that will eventually make calls to a standalone service (Contract B) hosted by the client. At design-time when the client queries my service's WSDL to build its proxy, I'd like to include the WSDL for Cont

  • Adding methods to DataContract objects for WCF 2010-09-17

    Are DataContracts in WCF nothing more than DTOs? I was reading up about WCF and just had a couple of thoughts. It would be nice if some of the DataContract objects could have methods on them so that the client could do basic things with them before o

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.097 (s). 11 q(s)