none
Conversion C# to VB .Net RRS feed

  • Question

  • Hello.

    I have an code, write in C#:

    [SoapDocumentMethod("http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Bare)]
    [return: XmlElement("nfeResultMsg", Namespace = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")]
    [WebMethod(MessageName = "nfeStatusServicoNF")]
    public XmlNode Execute([XmlElement(Namespace = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")] XmlNode nfeDadosMsg)
    {
        var results = Invoke("nfeStatusServicoNF", new object[] { nfeDadosMsg });
        return (XmlNode)(results[0]);
    }

    Using Telerik Code Converter (http://converter.telerik.com/), the code in VB .Net is:

    <SoapDocumentMethod("http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Bare)>
    <XmlElement("nfeResultMsg", [Namespace]:="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")>
    <WebMethod(MessageName:="nfeStatusServicoNF")>
    Public Function Execute(
    <XmlElement([Namespace]:="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")> ByVal nfeDadosMsg As XmlNode) As XmlNode
        Dim results = Invoke("nfeStatusServicoNF", New Object() {nfeDadosMsg})
        Return CType((results(0)), XmlNode)
    End Function

    However, apparently, the XmlElement (in VB .Net) can't be applied with Public Function. So, the translated code, can't be used.

    Help-me with this translate! =)

    Monday, October 22, 2018 4:27 PM

Answers

  • Try moving the attribute of the return type:

    <SoapDocumentMethod("http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Bare)>
    <WebMethod(MessageName:="nfeStatusServicoNF")>
    Public Function Execute(<XmlElement([Namespace]:="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")> ByVal nfeDadosMsg As XmlNode) As <XmlElement("nfeResultMsg", [Namespace]:="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")> XmlNode
        Dim results = Invoke("nfeStatusServicoNF", New Object() {nfeDadosMsg})
        Return CType((results(0)), XmlNode)
    End Function




    Monday, October 22, 2018 5:33 PM

All replies

  • Try moving the attribute of the return type:

    <SoapDocumentMethod("http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Bare)>
    <WebMethod(MessageName:="nfeStatusServicoNF")>
    Public Function Execute(<XmlElement([Namespace]:="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")> ByVal nfeDadosMsg As XmlNode) As <XmlElement("nfeResultMsg", [Namespace]:="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4")> XmlNode
        Dim results = Invoke("nfeStatusServicoNF", New Object() {nfeDadosMsg})
        Return CType((results(0)), XmlNode)
    End Function




    Monday, October 22, 2018 5:33 PM
  • It worked realy fine. Thanks.

    Now, I recieved another error: "The Path property must be set before the Send method call" when running:

    Dim results = Invoke("nfeStatusServicoNF", New Object() {nfeDadosMsg})

    Can you help me, with this new error?

    Monday, October 22, 2018 6:55 PM