WCF-公开来自内部调用的Web服务的数据合同数据

时间:2018-10-04 12:30:00

标签: c# .net wcf soap

我正在设计一个WCF Web服务(SOAP),它需要调用另一个Web服务来检索信息,然后在更改某些数据后返回巨大的对象。

我想知道:我是否必须创建一个映射器才能将Web服务返回的巨大对象映射到我的Datacontrat上,还是可以直接公开该对象?

这是我内部调用中的对象摘录:

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.2053.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://foo.fr/LireContractGeneric/1")]
public partial class TechnicalData : object, System.ComponentModel.INotifyPropertyChanged {

    private string checksumAgreementField;

    private string checkSumFleetField;

    private string billingVersionCodeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=0)]
    public string ChecksumAgreement {
        get {
            return this.checksumAgreementField;
        }
        set {
            this.checksumAgreementField = value;
            this.RaisePropertyChanged("ChecksumAgreement");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=1)]
    public string CheckSumFleet {
        get {
            return this.checkSumFleetField;
        }
        set {
            this.checkSumFleetField = value;
            this.RaisePropertyChanged("CheckSumFleet");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=2)]
    public string BillingVersionCode {
        get {
            return this.billingVersionCodeField;
        }
        set {
            this.billingVersionCodeField = value;
            this.RaisePropertyChanged("BillingVersionCode");
        }
    }

这是我想展示TechnicalData对象的DataContract的示例:

[MessageContract(WrapperName = "GetAgreementForProductionActResponse", WrapperNamespace = "http://foo.fr/ContratsIARD/VehicleAgreementForProductionAct/1")]
public class GetAgreementForProductionActResponse
{
    [MessageBodyMember(Name = "ReturnCode")]
    public string ReturnCode { get; set; }

    [MessageBodyMember(Name = "Anomaly")]
    public Anomaly Anomaly { get; set; }

    [MessageBodyMember(Name = "TechnicalData")]
    public TechnicalData TechnicalData { get; set; }
}

有可能做到吗? 我是否需要修改reference.cs在每个属性上添加MessageBodyMember装饰? 有人对此有可行的例子吗?

0 个答案:

没有答案