Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Web Server qtsoap
Forum Updated to NodeBB v4.3 + New Features

Web Server qtsoap

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 6.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Renatosantos
    wrote on last edited by
    #1

    How to create and send a xml to a web server.
    The XML looks like this:
    @
    POST /NfeRecepcao2/NfeRecepcao2.asmx HTTP/1.1
    Host: www.sefazvirtual.fazenda.gov.br
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2/nfeRecepcaoLote2"

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    soap:Header
    <nfeCabecMsg >
    <versaoDados>string</versaoDados>
    <cUF>string</cUF>
    </nfeCabecMsg>
    </soap:Header>
    soap:Body
    <nfeDadosMsg >file .xml</nfeDadosMsg>
    </soap:Body>
    </soap:Envelope>@

    I need create and send using qtsoap or something else.
    I created but was not equal.

    @
    QtSoapMessage msg;

    transport.setHost("www.sefazvirtual.fazenda.gov.br",443);
    connect(&transport, SIGNAL(responseReady()),this,SLOT(getResponse()));
    
    msg.setMethod("nfeDadosMsg","http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2");
    msg.addMethodArgument("versaoDados","","2.0");
    msg.addMethodArgument("cUF","","MA");
    msg.addMethodArgument("nfeDadosMsg","","C:\\QtSDK\\QtCreator\\NFe\\testaNFe\\arquivo.xml");
    transport.setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2/nfeRecepcaoLote2");
    transport.submitRequest(msg, "/nfeRecepcao/nfeRecepcao2.asmx");
    

    //======
    //out
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <nfeDadosMsg >
    <versaoDados xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">2.0</versaoDados>
    <cUF xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">MA</cUF>
    <nfeDadosMsg xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">C:\QtSDK\QtCreator\NFe\testaNFe\arquivo.xml</nfeDadosMsg>
    </nfeDadosMsg>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    @

    Qt Developer.

    "Imagination is more important than knowledge."
    http://twitter.com/Renatos20

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      "versaoDados" and "cUF" are not method arguments. In your example they are in the SOAP Header. I am not sure if the qtsoap implementation had support for SOAP Header Entries.

      If this is your only request (or one of only a few) it may be easier to simply use QXmlStreamWriter to produce exactly the XML you want.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Renatosantos
        wrote on last edited by
        #3

        ok, i believe too that qtsoap can not implement the header. If i create with the QXmlStreamWrite how can i send for a web server using the Qt?

        Qt Developer.

        "Imagination is more important than knowledge."
        http://twitter.com/Renatos20

        1 Reply Last reply
        0
        • jazzycamelJ Offline
          jazzycamelJ Offline
          jazzycamel
          wrote on last edited by
          #4

          You can post HTTP requests and receive responses using "QNetworkAccessManager":http://qt-project.org/doc/qt-4.8/qnetworkaccessmanager.html. You would pass the output from QXmlStreamWrite to post() along with a "QNetworkRequest":http://qt-project.org/doc/qt-4.8/qnetworkrequest.html object. You can set the "SOAPAction" value in the request using its setRawHeader method and the content type using setHeader (as its a known header). You will receive your response in the form of a "QNetworkReply":http://qt-project.org/doc/qt-4.8/qnetworkreply.html via the managers finished signal.

          I've just finished creating a custom JSON-RPC library using this method and these classes and its works very nicely.

          For the avoidance of doubt:

          1. All my code samples (C++ or Python) are tested before posting
          2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
          1 Reply Last reply
          0
          • R Offline
            R Offline
            Renatosantos
            wrote on last edited by
            #5

            Thanks guys, I'm using QNetWorkAccessManeger and everything is ok now.
            ;)

            Qt Developer.

            "Imagination is more important than knowledge."
            http://twitter.com/Renatos20

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved