none
Problema en respuesta de método RRS feed

  • Pregunta

  • Buenas tardes,

    A través del WSDL (adjunto fichero Descriptor.wsdl), he generado en el VS2010 un proxy para comunicar con el servidor. El proxy generado (adjunto reference.cs), me genera un interfaz con dos métodos, los que implementa el Web Service:

    • GetArticulosCofasDirectoByCodCliente
    • getContratos

    El problema lo tengo a la hora de obtener la respuesta al método “GetArticulosCofasDirectoByCodCliente”. Me salta la siguiente excepción: El objeto de tipo 'Cofas.CofasClient.contratoCF[]' no puede convertirse en el tipo 'Cofas.CofasClient.articuloCofasDirectoVO[]'. La respuesta se recibe ya que capturamos el soapResponse. El problema está al serializar el XML.

    Si comento el método getContratos y las clases que hacen referencia a este método en el “reference.cs”, o si en la definición del interface cambio el orden en el que se definen los métodos, poniendo primero el método

    GetArticulosCofasDirectoByCodCliente, funciona correctamente.

    He leído en foros, la opción de poner en la definición de la interfaz la propiedade System.ServiceModel.ServiceKnownType, pero siempre hablaban de casos en los que se define un inferaz que contiene un método con varios tipos de datos. Este no es mi caso.

    ¿Alguna idea?

    <?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="CofasDirectoSAPWSService" targetNamespace="http://ws.pubws.sap.sisrap.cofas.es/" xmlns:ns1="http://ws.pubws.sisrap.cofas.es/" xmlns:ns2="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.pubws.sap.sisrap.cofas.es/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <wsdl:import location="https://pedidos.cofas.es:8482/SisrapPublicWS/ws/CofasDirecto?wsdl=ICofasDirectoWS.wsdl" namespace="http://ws.pubws.sisrap.cofas.es/">
        </wsdl:import>
      <wsdl:binding name="CofasDirectoSAPWSServiceSoapBinding" type="ns1:ICofasDirectoWS">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="getContratos">
          <soap:operation soapAction="" style="rpc" />
          <wsdl:input name="getContratos">
            <soap:body namespace="http://ws.pubws.sisrap.cofas.es/" use="literal" />
          </wsdl:input>
          <wsdl:output name="getContratosResponse">
            <soap:body namespace="http://ws.pubws.sisrap.cofas.es/" use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="GetArticulosCofasDirectoByCodCliente">
          <soap:operation soapAction="" style="rpc" />
          <wsdl:input name="GetArticulosCofasDirectoByCodCliente">
            <soap:body namespace="http://ws.pubws.sisrap.cofas.es/" use="literal" />
          </wsdl:input>
          <wsdl:output name="GetArticulosCofasDirectoByCodClienteResponse">
            <soap:body namespace="http://ws.pubws.sisrap.cofas.es/" use="literal" />
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="CofasDirectoSAPWSService">
        <wsdl:port binding="tns:CofasDirectoSAPWSServiceSoapBinding" name="CofasDirectoSAPWSPort">
          <soap:address location="https://pedidos.cofas.es:8482/SisrapPublicWS/ws/CofasDirecto" />
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     Este código fue generado por una herramienta.
    //     Versión de runtime:4.0.30319.18034
    //
    //     Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
    //     se vuelve a generar el código.
    // </auto-generated>
    //------------------------------------------------------------------------------
    
    namespace Cofas.ClienteCof {
        
        
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.ServiceContractAttribute(Namespace="http://ws.pubws.sisrap.cofas.es/", ConfigurationName="ClienteCof.ICofasDirectoWS")]
        public interface ICofasDirectoWS {
            
            [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
            [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
            Cofas.ClienteCof.getContratosResponse getContratos(Cofas.ClienteCof.getContratos request);
            
            [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
            [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
            Cofas.ClienteCof.GetArticulosCofasDirectoByCodClienteResponse GetArticulosCofasDirectoByCodCliente(Cofas.ClienteCof.GetArticulosCofasDirectoByCodCliente request);
        }
        
        /// <comentarios/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18034")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://ws.pubws.sisrap.cofas.es/")]
        public partial class contratoCFFiltro : object, System.ComponentModel.INotifyPropertyChanged {
            
            private string codArticuloField;
            
            private string codClienteField;
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=0)]
            public string codArticulo {
                get {
                    return this.codArticuloField;
                }
                set {
                    this.codArticuloField = value;
                    this.RaisePropertyChanged("codArticulo");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=1)]
            public string codCliente {
                get {
                    return this.codClienteField;
                }
                set {
                    this.codClienteField = value;
                    this.RaisePropertyChanged("codCliente");
                }
            }
            
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            
            protected void RaisePropertyChanged(string propertyName) {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null)) {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }
        
        /// <comentarios/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18034")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://ws.pubws.sisrap.cofas.es/")]
        public partial class articuloCofasDirectoVO : object, System.ComponentModel.INotifyPropertyChanged {
            
            private int cantConsClienteField;
            
            private int cantRemanenteField;
            
            private int cantTotalField;
            
            private string codArticuloField;
            
            private string nombreArticuloField;
            
            private decimal pDescuentoField;
            
            private bool pDescuentoFieldSpecified;
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
            public int cantConsCliente {
                get {
                    return this.cantConsClienteField;
                }
                set {
                    this.cantConsClienteField = value;
                    this.RaisePropertyChanged("cantConsCliente");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
            public int cantRemanente {
                get {
                    return this.cantRemanenteField;
                }
                set {
                    this.cantRemanenteField = value;
                    this.RaisePropertyChanged("cantRemanente");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)]
            public int cantTotal {
                get {
                    return this.cantTotalField;
                }
                set {
                    this.cantTotalField = value;
                    this.RaisePropertyChanged("cantTotal");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)]
            public string codArticulo {
                get {
                    return this.codArticuloField;
                }
                set {
                    this.codArticuloField = value;
                    this.RaisePropertyChanged("codArticulo");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)]
            public string nombreArticulo {
                get {
                    return this.nombreArticuloField;
                }
                set {
                    this.nombreArticuloField = value;
                    this.RaisePropertyChanged("nombreArticulo");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)]
            public decimal pDescuento {
                get {
                    return this.pDescuentoField;
                }
                set {
                    this.pDescuentoField = value;
                    this.RaisePropertyChanged("pDescuento");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool pDescuentoSpecified {
                get {
                    return this.pDescuentoFieldSpecified;
                }
                set {
                    this.pDescuentoFieldSpecified = value;
                    this.RaisePropertyChanged("pDescuentoSpecified");
                }
            }
            
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            
            protected void RaisePropertyChanged(string propertyName) {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null)) {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }
        
        /// <comentarios/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18034")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://ws.pubws.sisrap.cofas.es/")]
        public partial class contratoCF : object, System.ComponentModel.INotifyPropertyChanged {
            
            private int cantConsClienteField;
            
            private int cantRemanenteField;
            
            private int cantTotalField;
            
            private string codArticuloField;
            
            private System.Nullable<System.DateTime> fechaFinField;
            
            private bool fechaFinFieldSpecified;
            
            private string nombreArticuloField;
            
            private string nombreGrupoField;
            
            private decimal pDescuentoField;
            
            private bool pDescuentoFieldSpecified;
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
            public int cantConsCliente {
                get {
                    return this.cantConsClienteField;
                }
                set {
                    this.cantConsClienteField = value;
                    this.RaisePropertyChanged("cantConsCliente");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
            public int cantRemanente {
                get {
                    return this.cantRemanenteField;
                }
                set {
                    this.cantRemanenteField = value;
                    this.RaisePropertyChanged("cantRemanente");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)]
            public int cantTotal {
                get {
                    return this.cantTotalField;
                }
                set {
                    this.cantTotalField = value;
                    this.RaisePropertyChanged("cantTotal");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)]
            public string codArticulo {
                get {
                    return this.codArticuloField;
                }
                set {
                    this.codArticuloField = value;
                    this.RaisePropertyChanged("codArticulo");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=4)]
            public System.Nullable<System.DateTime> fechaFin {
                get {
                    return this.fechaFinField;
                }
                set {
                    this.fechaFinField = value;
                    this.RaisePropertyChanged("fechaFin");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool fechaFinSpecified {
                get {
                    return this.fechaFinFieldSpecified;
                }
                set {
                    this.fechaFinFieldSpecified = value;
                    this.RaisePropertyChanged("fechaFinSpecified");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)]
            public string nombreArticulo {
                get {
                    return this.nombreArticuloField;
                }
                set {
                    this.nombreArticuloField = value;
                    this.RaisePropertyChanged("nombreArticulo");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=6)]
            public string nombreGrupo {
                get {
                    return this.nombreGrupoField;
                }
                set {
                    this.nombreGrupoField = value;
                    this.RaisePropertyChanged("nombreGrupo");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=7)]
            public decimal pDescuento {
                get {
                    return this.pDescuentoField;
                }
                set {
                    this.pDescuentoField = value;
                    this.RaisePropertyChanged("pDescuento");
                }
            }
            
            /// <comentarios/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool pDescuentoSpecified {
                get {
                    return this.pDescuentoFieldSpecified;
                }
                set {
                    this.pDescuentoFieldSpecified = value;
                    this.RaisePropertyChanged("pDescuentoSpecified");
                }
            }
            
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            
            protected void RaisePropertyChanged(string propertyName) {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null)) {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.MessageContractAttribute(WrapperName="getContratos", WrapperNamespace="http://ws.pubws.sisrap.cofas.es/", IsWrapped=true)]
        public partial class getContratos {
            
            [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
            public Cofas.ClienteCof.contratoCFFiltro filtro;
            
            public getContratos() {
            }
            
            public getContratos(Cofas.ClienteCof.contratoCFFiltro filtro) {
                this.filtro = filtro;
            }
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.MessageContractAttribute(WrapperName="getContratosResponse", WrapperNamespace="http://ws.pubws.sisrap.cofas.es/", IsWrapped=true)]
        public partial class getContratosResponse {
            
            [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
            [System.Xml.Serialization.XmlArrayAttribute()]
            [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public Cofas.ClienteCof.contratoCF[] @return;
            
            public getContratosResponse() {
            }
            
            public getContratosResponse(Cofas.ClienteCof.contratoCF[] @return) {
                this.@return = @return;
            }
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.MessageContractAttribute(WrapperName="GetArticulosCofasDirectoByCodCliente", WrapperNamespace="http://ws.pubws.sisrap.cofas.es/", IsWrapped=true)]
        public partial class GetArticulosCofasDirectoByCodCliente {
            
            [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
            public string codCliente;
            
            public GetArticulosCofasDirectoByCodCliente() {
            }
            
            public GetArticulosCofasDirectoByCodCliente(string codCliente) {
                this.codCliente = codCliente;
            }
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.MessageContractAttribute(WrapperName="GetArticulosCofasDirectoByCodClienteResponse", WrapperNamespace="http://ws.pubws.sisrap.cofas.es/", IsWrapped=true)]
        public partial class GetArticulosCofasDirectoByCodClienteResponse {
            
            [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
            [System.Xml.Serialization.XmlArrayAttribute()]
            [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public Cofas.ClienteCof.articuloCofasDirectoVO[] @return;
            
            public GetArticulosCofasDirectoByCodClienteResponse() {
            }
            
            public GetArticulosCofasDirectoByCodClienteResponse(Cofas.ClienteCof.articuloCofasDirectoVO[] @return) {
                this.@return = @return;
            }
        }
        
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        public interface ICofasDirectoWSChannel : Cofas.ClienteCof.ICofasDirectoWS, System.ServiceModel.IClientChannel {
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        public partial class CofasDirectoWSClient : System.ServiceModel.ClientBase<Cofas.ClienteCof.ICofasDirectoWS>, Cofas.ClienteCof.ICofasDirectoWS {
            
            public CofasDirectoWSClient() {
            }
            
            public CofasDirectoWSClient(string endpointConfigurationName) : 
                    base(endpointConfigurationName) {
            }
            
            public CofasDirectoWSClient(string endpointConfigurationName, string remoteAddress) : 
                    base(endpointConfigurationName, remoteAddress) {
            }
            
            public CofasDirectoWSClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                    base(endpointConfigurationName, remoteAddress) {
            }
            
            public CofasDirectoWSClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                    base(binding, remoteAddress) {
            }
            
            public Cofas.ClienteCof.getContratosResponse getContratos(Cofas.ClienteCof.getContratos request) {
                return base.Channel.getContratos(request);
            }
            
            public Cofas.ClienteCof.GetArticulosCofasDirectoByCodClienteResponse GetArticulosCofasDirectoByCodCliente(Cofas.ClienteCof.GetArticulosCofasDirectoByCodCliente request) {
                return base.Channel.GetArticulosCofasDirectoByCodCliente(request);
            }
        }
    }
    


    martes, 15 de noviembre de 2016 17:47