Click here to Skip to main content
15,392,858 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I use httpwebrequest to call wcf service.

I didn't add service reference or created a client proxy.

I have a problem. How to access DataContract class and set datamember values..?

I have a wsdl file. I can't use proxy class or add service reference .

I have seen many samples passing xml string(created manually) in request stream.

How can I access datacontract classes using this htpwebrequest..?

any suggestion is appreciated.
Not clear. The whole purpose of Data Contract is to serialize and deserialize some arbitrary object graph.
There is no such thing as "how to access a class". You receive a reference to the object representing an object graph.
[no name] 18-Nov-13 7:47am
I mean how can I set values to datacontract object...!
How can I discover that, the service expose datacontract class using the httpwebrequest and not service reference. by service reference, one can know the datacontract class members.
Sergey Alexandrovich Kryukov 18-Nov-13 12:55pm
Please see my answer.

1 solution

From stream on in your code? The object comes deserialized with the use of DataContractSerializer, please see. It is controlled by [DataMember] attributes and does not require anything, not even access modifiers. Please see:[^],[^].

If you need to access something from your semantic code, you need to make a property (properties) for that, or add internal or public access modifier to existing property (properties). Internal for access from the same assembly, public for access from other (referencing) assemblies. Please see:[^],
Conversion failed when converting date and/or time from character string.?[^],[^],[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900