Reputation: 6619
I have defined a MessageContract
in order to transfer a Stream
along with some other data via WCF:
[MessageContract]
public class DTSetGeotagImageMessage
{
[MessageHeader(MustUnderstand = true)]
public DTGeotagImageFileInfo GeotagImageFileInfo;
[MessageBodyMember(Order = 1)]
public Stream FileData;
}
public class DTGeotagImageFileInfo
{ //All these properties are not showing up in the WSDL:
public long? GeotagID { get; internal set; }
public string GeotagGuid { get; internal set; }
public string ImageGuid { get; internal set; }
public long GeotagFieldId { get; internal set; }
public double Lat { get; internal set; }
public double Lon { get; internal set; }
}
WSDL:
<xs:complexType name="DTGeotagImageFileInfo">
<xs:sequence/>
</xs:complexType>
<xs:element name="DTGeotagImageFileInfo" nillable="true" type="tns:DTGeotagImageFileInfo"/>
But the properties of the header data class is not showing up in the WSDL file. How do I get them to show up?
Upvotes: 0
Views: 672
Reputation: 71
Service Contract access modifiers on DataContracts/DataMembers do not play any role. .NET setter and getter visibility modifier are irrelevant when dealing with WCF messages, as long as you tag them accordingly:
//Tag DataContract and DataMember for serialization
[DataContract]
public class DTGeotagImageFileInfo
{
[DataMember]
public long? GeotagID { get; internal set; }
[DataMember]
public string GeotagGuid { get; internal set; }
[DataMember]
public string ImageGuid { get; internal set; }
[DataMember]
public long GeotagFieldId { get; internal set; }
[DataMember]
public double Lat { get; internal set; }
[DataMember]
public double Lon { get; internal set; }
}
Upvotes: 0
Reputation: 6619
It turns out MessageContract
properties must have a public
setter in order to be seen by the code that generates the code:
public class DTGeotagImageFileInfo
{
public long? GeotagID { get; set; }
public string GeotagGuid { get; set; }
public string ImageGuid { get; set; }
public long GeotagFieldId { get; set; }
public double Lat { get; set; }
public double Lon { get; set; }
}
WSDL:
<xs:complexType name="DTGeotagImageFileInfo">
<xs:sequence>
<xs:element minOccurs="0" name="GeotagFieldId" type="xs:long"/>
<xs:element minOccurs="0" name="GeotagGuid" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="GeotagID" nillable="true" type="xs:long"/>
<xs:element minOccurs="0" name="ImageGuid" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="Lat" type="xs:double"/>
<xs:element minOccurs="0" name="Lon" type="xs:double"/>
</xs:sequence>
</xs:complexType>
<xs:element name="DTGeotagImageFileInfo" nillable="true"
type="tns:DTGeotagImageFileInfo"/>
Upvotes: 0