Questions tagged [messagecontract]

Windows Communication Foundation (WCF) MessageContract Attribute defines a strongly-typed class that corresponds to a SOAP message.

Windows Communication Foundation (WCF) MessageContract Attribute allows complete control over the structure of a SOAP message. This is especially important for interoperability or to specifically control security issues at the level of the message or message part. In these cases, you can create a message contract that enables you to specify the structure of the precise SOAP message required.

To define a message contract for a type (that is, to define the mapping between the type and a SOAP envelope), apply the MessageContractAttribute to the type. Then apply the MessageHeaderAttribute to those members of the type you want to make into SOAP headers, and apply the MessageBodyMemberAttribute to those members you want to make into parts of the SOAP body of the message.

In the SOAP representation of a message contract, each header and body part maps to an XML element that has a name and a namespace. By default, the namespace is the same as the namespace of the service contract that the message is participating in, and the name is determined by the member name to which the MessageHeaderAttribute or the MessageBodyMemberAttribute attributes are applied.

http://msdn.microsoft.com/en-us/library/ms730255(v=vs.110).aspx

84 questions
3
votes
1 answer

MessageContract serialization with DCS

Is there a way to make the DataContractSerializer serialize a [MessageContract] the same way it appears when transmitted over SOAP? I have a class that appears as follows on the wire for a WCF call:
kurtaj
  • 31
  • 2
3
votes
1 answer

WCF Serialising Enums using Message Contracts

I have some web services that use Message contracts. It's probably worth mentioning that for these services, I cannot shift to Data contracts... One of my types specifies a property whose type happens to be an…
Robert
  • 1,487
  • 1
  • 14
  • 26
3
votes
1 answer

WCF MessageContract wrapping and lists

I've received a specification from a customer of how their web-service client works. The specification is the actual SOAP XML messages that are sent and received from the service as well as the corresponding XSD. The customer want me to implement a…
Schtibb
  • 151
  • 2
  • 8
3
votes
6 answers

WCF MessageContract Inheritance

I am fairly new to WCF and just have a question on how to correctly get MessageContract inheritance working. A simplified version of my setup is as follows - a "base" message type, and then another "test" message which inherits from…
Frank Bell
  • 139
  • 1
  • 7
3
votes
1 answer

WCF Streaming File Issue

Is it possible to stream a file using WCF with a MessageContract that contains another MessageContract that has the Stream inside it? I think the answer is no, but I'd much prefer to package my file inside a "Root" message so to speak. In otherwords…
Tada
  • 1,585
  • 2
  • 16
  • 26
3
votes
1 answer

MessageHeader Issue in WCF

I have two separate message contracts in WCF: [MessageContract(WrapperName = "GetFooRequest", WrapperNamespace = "http://whatever.services.schema")] public class GetFooRequest { [MessageHeader] public int ResponseType { get; set; } …
Dismissile
  • 32,564
  • 38
  • 174
  • 263
2
votes
0 answers

Is it possible to mix streamed transfer and non streamed transfer WCF OperationContracts within the same service?

I have a set of operations that are defined within a single ServiceContract and now two of them have been switched over to take and return MessageContracts directly which contain a Stream body as outlined within the MSDN documentation. I've tested…
jpierson
  • 16,435
  • 14
  • 105
  • 149
2
votes
4 answers

How to serialize nested types in WCF response?

Scenario: I'm in the process of creating a WCF service that exposes user data. An instance of User has a property called Role. If I omit this property, the service works; if don't omit the property, the service fails. Below is a (very) simplified…
Herman Cordes
  • 4,628
  • 9
  • 51
  • 87
2
votes
1 answer

WCF Webservice pass messagecontract with Stream and return a string to Client

I want to create WCF web service to recalculate the formula of .xlsx and .xls files(want to determine the extension type in service and return back processed fileID back to client and then another service method to get file from the returned…
user2015
  • 63
  • 8
2
votes
2 answers

WCF when to use MessageHeader rather than passing variable in function argument

I am reading about MessageContract & MessageHeader and trying to understand the use case of sending some info in MessageHeader and not use it just as a function parameters?
Silverlight Student
  • 3,968
  • 10
  • 37
  • 53
2
votes
1 answer

How to ignore the property of the base class in the derived class while using the XmlSerializer?

I have a class like this: [Serializable] public class Structure { #region Constants and Fields /// /// The description. /// private string description; #endregion …
Learner
  • 4,661
  • 9
  • 56
  • 102
2
votes
2 answers

How are message contracts versioned for service buses?

Let's say we use message contracts based on interfaces, as recommended for MassTransit for example. First how are those interfaces shared across all the applications? Let's say we provide them in a nuget package. (Is that the way to go?) So second,…
SwissCoder
  • 2,514
  • 4
  • 28
  • 40
2
votes
2 answers

Method parameter is missing in WCF proxy class

I have a WCF method defined as below: [OperationContract] Message GetSourceData(SourceDataQuery sourceDataQuery); And actual implementation is something like this: public Message GetSourceData(SourceDataQuery sourceDataQuery) { …
Otake
  • 874
  • 3
  • 8
  • 21
2
votes
1 answer

Adding multiple namespaces to MessageContract WCF response object (MessageBodyMember)

We have a WCF setup with the following contracts: [ServiceContract( Namespace = Constants.Namespaces.HL7Namespace, Name = Constants.Roles.ContentRequiredDocumentManagementSystem)] // XmlSerializerFormat is needed to expose the HL7 schema…
Bensonius
  • 1,501
  • 1
  • 15
  • 39
2
votes
0 answers

WCF MessageContract complex type property not deserializing

I have to implement a service to handle this SOAP message:
Soaper
  • 31
  • 2