Sample code for 30+ languages & platforms
Java

SOAP Request to fseservicetest.sanita.finanze.it with Basic Authentication

See more HTTP Misc Examples

Demonstrates sending a SOAP request to fseservicetest.sanita.finanze.it with Basic Authentication.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpRequest;
import com.chilkatsoft.chilkat2.HttpResponse;
import com.chilkatsoft.chilkat2.Xml;

public class ChilkatExample {

    public static void main(String[] args) {
        boolean success = false;

        // This example requires the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();
        Xml xml = new Xml();

        success = false;

        // Create the SOAP envelope...
        xml.setTag("soapenv:Envelope");
        xml.addAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
        xml.addAttribute("xmlns:stat", "http://statoconsensirichiesta.xsd.fse.ini.finanze.it");
        xml.addAttribute("xmlns:tip", "http://tipodatistatoconsensi.xsd.fse.ini.finanze.it");
        xml.updateChildContent("soapenv:Header", "");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoUtente", "XXXXXXAAABBBCCC");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:pinCode", "...");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoOrganizzazione", "999");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:StrutturaUtente", "123456789");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:RuoloUtente", "ZZZ");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:ContestoOperativo", "");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoGenitoreTutore", "");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:PresaInCarico", "true");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:TipoAttivita", "READ");
        xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoConsenso", "ABCDEFGHIJKLM");
        String soapEnvelope = xml.getXml();

        String domain = "fseservicetest.sanita.finanze.it";
        String path = "/FseInsServicesWeb/services/fseStatoConsensi";

        HttpRequest req = new HttpRequest();
        req.setHttpVerb("POST");
        req.setSendCharset(false);
        req.addHeader("Content-Type", "application/soap+xml; charset=utf-8");
        req.setPath(path);
        req.loadBodyFromString(soapEnvelope, "utf-8");

        // User name and Password for Basic Authentication
        http.setLogin("XXXXXXAAABBBCCC");
        http.setPassword("MYPASSWORD");

        HttpResponse resp = new HttpResponse();
        try {
            http.httpSReq(domain, 443, true, req, resp);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        Xml xmlResp = new Xml();
        xmlResp.loadXml(resp.getBodyStr());
        System.out.println(xmlResp.getXml());
    }
}