1

Necesito su ayuda nuevamente, estoy tratando de recuperar algunos elementos de una respuesta de Soap y estoy atascado.

Así es como trato de hacer la respuesta:

 using(new OperationContextScope(client.InnerChannel))
            {
                SoapAuthenticationHeader.Create(client.ClientCredentials.UserName.UserName, client.ClientCredentials.UserName.Password);

                zWsCustomerInvoiceGetList.Customerid = cuit;

                ZWsCustomerInvoiceGetListResponse1 zWsCustomerInvoiceGetListResponse1 = await client.ZWsCustomerInvoiceGetListAsync(zWsCustomerInvoiceGetList);

            }

Y este public void SoapAuthenticationHeader.Create(), por lo que envío la autenticación básica como encabezados:

public static void Create(string username, string password)
    {
        string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(username + ":" + password));

        HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
        requestMessage.Headers.Add("Authorization", auth);
        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
    }

Usando esto, la respuesta solo trae elementos vacíos.

introducir la descripción de la imagen aquí

Después de esto, pensé que era porque no estaba usando await client.OpenAsync(); de Reference.cs, pero si hago el método OpenAsync tengo esta excepción:

System.InvalidOperationException: 'El objeto de comunicación, System.ServiceModel.ChannelFactory`1[ServiceReference1.Z_WS_CUSTOMER_INVOICE_GET_LIST], no se puede modificar mientras está en estado Abierto.'

Lo siento si esta es una pregunta de novato, pero no puedo entender qué hacer. ¿Tal vez tengo que enviar todos los elementos XML vacíos para tener una respuesta?

EDIT:

Agrego mi Reference.cs

 /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
[DataContract]
public partial class ZWsCustomerInvoiceGetList
{
    [XmlElement(Order = 1)]
    private string customeridField;
    
    [XmlElement(Order = 2)]
    private string pedidoCliField;
    
    [XmlElement(Order = 3)]
    private string pedidoSapField;

    [XmlElement(Order = 4)]
    private ZfacturaMat[] tFacturaMatField;

    [XmlElement(Order = 5)]
    public List<ZfacturaMat> zfacturaMats;

    [XmlElement(Order = 6)]
    private ZinvoiceList[] tInvoicesField;

    [XmlElement(Order = 7)]
    public List<ZinvoiceList> invoicesField;

    [XmlElement(Order = 8)]
    private Bapiret1[] tReturnField;
    
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
    public string Customerid
    {
        get
        {
            return this.customeridField;
        }
        set
        {
            this.customeridField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
    public string PedidoCli
    {
        get
        {
            return this.pedidoCliField;
        }
        set
        {
            this.pedidoCliField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)]
    public string PedidoSap
    {
        get
        {
            return this.pedidoSapField;
        }
        set
        {
            this.pedidoSapField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public ZfacturaMat[] TFacturaMat
    {
        get
        {
            return this.tFacturaMatField;
        }
        set
        {
            this.tFacturaMatField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public ZinvoiceList[] TInvoices
    {
        get
        {
            return this.tInvoicesField;
        }
        set
        {
            this.tInvoicesField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=5)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public Bapiret1[] TReturn
    {
        get
        {
            return this.tReturnField;
        }
        set
        {
            this.tReturnField = value;
        }
    }
}

    [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class ZWsCustomerInvoiceGetListRequest
{
    
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:sap-com:document:sap:soap:functions:mc-style", Order=0)]
    public ServiceReference1.ZWsCustomerInvoiceGetList ZWsCustomerInvoiceGetList;
    
    public ZWsCustomerInvoiceGetListRequest()
    {
    }
    
    public ZWsCustomerInvoiceGetListRequest(ServiceReference1.ZWsCustomerInvoiceGetList ZWsCustomerInvoiceGetList)
    {
        this.ZWsCustomerInvoiceGetList = ZWsCustomerInvoiceGetList;
    }
}


    [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class ZWsCustomerInvoiceGetListResponse1
{
    
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:sap-com:document:sap:soap:functions:mc-style", Order=0)]
    public ServiceReference1.ZWsCustomerInvoiceGetListResponse ZWsCustomerInvoiceGetListResponse;
    
    public ZWsCustomerInvoiceGetListResponse1()
    {
    }
    
    public ZWsCustomerInvoiceGetListResponse1(ServiceReference1.ZWsCustomerInvoiceGetListResponse ZWsCustomerInvoiceGetListResponse)
    {
        this.ZWsCustomerInvoiceGetListResponse = ZWsCustomerInvoiceGetListResponse;
    }
}

        public async System.Threading.Tasks.Task<ServiceReference1.ZWsCustomerInvoiceGetListResponse1> ZWsCustomerInvoiceGetListAsync(ServiceReference1.ZWsCustomerInvoiceGetList ZWsCustomerInvoiceGetList)
    {
        ServiceReference1.ZWsCustomerInvoiceGetListRequest inValue = new ServiceReference1.ZWsCustomerInvoiceGetListRequest();
        inValue.ZWsCustomerInvoiceGetList = ZWsCustomerInvoiceGetList;
        return await((ServiceReference1.Z_WS_CUSTOMER_INVOICE_GET_LIST)(this)).ZWsCustomerInvoiceGetListAsync(inValue);
    }
    

EDIT:

Por lo que estuve investigando, tengo posiblemente un problema en el Order o un tema de NameSpace, pero no estoy muy seguro.

1
  • El channelFactory ya esta resuelto el 30 may. 2022 a las 15:54

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.