wcf soap 1.1 объект ответа не десериализован - PullRequest
0 голосов
/ 21 ноября 2018

У меня есть клиент .NET 4.5, вызывающий метод службы мыла.Метод вызывается корректно по кабелю с помощью fiddler, я могу сказать, что ответ возвращается и вызов метода завершился успешно.

Пример ответа на вызов метода:

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
    <executeResponse>
        <Number>EEI0002278</Number>
        <SysID>a2750b4fdbb9a7c0b6e69b3c8a9619ff</SysID>
        <Status>200</Status>
        <Message>COI case generated</Message>
    </executeResponse>
</SOAP-ENV:Body>

Файл моего клиента .config

 <system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="WsHttpSoap11">
                <security enableUnsecuredResponse="true" authenticationMode="CertificateOverTransport" />
                <textMessageEncoding messageVersion="Soap11" />
                <context />
                <httpsTransport authenticationScheme="Basic" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="https://gateway-cs.company.com:8888/COICaseGenerator.do"
            binding="customBinding" bindingConfiguration="WsHttpSoap11"
            contract="ServiceNowSoap" name="Soap11" />
    </client>
</system.serviceModel>

Данные контракта:

[DataContract(Namespace = "http://www.company.com/COICaseGenerator")]
public class executeResponse
{

    private string numberField;
    private string sysIDField;
    private string statusField;
    private string messageField;

    [DataMember(Name="Number", Order = 0)]
    public string Number
    {
        get
        {
            return this.numberField;
        }
        set
        {
            this.numberField = value;
        }
    }

    [DataMember(Name = "SysID", Order = 1)]
    public string SysID
    {
        get
        {
            return this.sysIDField;
        }
        set
        {
            this.sysIDField = value;
        }
    }

    [DataMember(Name = "Status", Order = 2)]
    public string Status
    {
        get
        {
            return this.statusField;
        }
        set
        {
            this.statusField = value;
        }
    }

    [DataMember(Name = "Message", Order = 3)]
    public string Message
    {
        get
        {
            return this.messageField;
        }
        set
        {
            this.messageField = value;
        }
    }

    [OnDeserialized()]
    public void OnDeserialized(StreamingContext c)
    {
        //if (MyCustonObj == null)
        //{
        //    MyCustonObj = new MyCustomClass();
        //    MyCustonObj.MyStrData = "Overridden in serialization";
        //}
    }

    [OnDeserializing()]
    public void OnDeserializing(StreamingContext c)
    {
        //if (MyCustonObj == null)
        //{
        //    MyCustonObj = new MyCustomClass();
        //    MyCustonObj.MyStrData = "Overridden in  deserializing";
        //}
    }

    [OnSerialized()]
    public void OnSerialized(StreamingContext c)
    {
        // if you wan to  do somehing when serialized here or just remove them

    }

    [OnSerializing()]
    public void OnSerializing(StreamingContext c)
    {
        // if you wan to  do somehing during serializing here or just remove them    
    }
}

Svcutil.сгенерированный exe:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="", ConfigurationName="ServiceNowSoap")]
public interface ServiceNowSoap
{

    [System.ServiceModel.OperationContractAttribute()]
    executeResponse execute(CoiCase coiCase);

    [System.ServiceModel.OperationContractAttribute()]
    void executeAsync();
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface ServiceNowSoapChannel : ServiceNowSoap, System.ServiceModel.IClientChannel
{
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class ServiceNowSoapClient : System.ServiceModel.ClientBase<ServiceNowSoap>, ServiceNowSoap
{

    public ServiceNowSoapClient()
    {
    }

    public ServiceNowSoapClient(string endpointConfigurationName) : 
            base(endpointConfigurationName)
    {
    }

    public ServiceNowSoapClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public ServiceNowSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress)
    {
    }

    public void executeAsync()
    {
        base.Channel.executeAsync();
    }

    public executeResponse execute(CoiCase coiCase)
    {
        return base.Channel.execute(coiCase);
    }
}

Проблема:

Вызов метода обслуживания (executeResponse execute (CoiCase coiCase)) возвращает ноль.Несмотря на то, что ответное сообщение выглядит корректно в Fiddler.

и следующие методы десериализации никогда не вызываются.Я устанавливаю контрольные точки, но они никогда не попадают.

public void OnDeserialized(StreamingContext c)
public void OnDeserializing(StreamingContext c)
public void OnSerialized(StreamingContext c)
public void OnSerializing(StreamingContext c)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...