How to generate an XML with envelope tags?

0
I have to generate an XML as below: <?xml version="1.0" encoding="UTF-16"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <dis:Login xmlns:dis="http://www.sap.com/SBO/DIS"> <DatabaseName>1531</DatabaseName> <CompanyUsername>Username</CompanyUsername> <CompanyPassword>Password</CompanyPassword> </dis:Login> </env:Body> </env:Envelope> But I am not sure how to construct my .xsd file in order to generate all the proper tags? Is it even possible to generate an XML that looks like this? Edit: I need to send a string to a URL endpoint (REST). I guess it would be possible to just create string variables in a microflow and then build the string like that? Create Var1: <?xml version="1.0" encoding="UTF-16"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><dis:Login xmlns:dis="http://www.sap.com/SBO/DIS"><DatabaseName> Create var2: $Var1 + $DatabseName/Name Etc.? Seems like a workaround that should be doable, but i'm not sure if there are any other ways around it (provided that I have 0 java experience/knowledge which makes it hard to implement a Java action that would do the above for me)
asked
1 answers
0

Hi Niels,

Here is a snippet to call soap from Java. Just a starting point... Watch the result processing, needs to be adapted to your situation.

            SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
            SOAPConnection soapConnection = soapConnectionFactory.createConnection();

            // Send SOAP Message to SOAP Server
            InputStream is = null;
            if (cacheType == CacheType.MEMORY) {
                is = new ByteArrayInputStream(this.request.getBytes());
            } 
            if (cacheType == CacheType.FILE) {
                splogger.info("read from file");
                is = new FileInputStream(this.fileName);
            } 
            // copy original message into this.
            SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(null, is);                 
            String url = YOURURL;
            splogger.trace("invoke url " + url);
            SOAPMessage soapResponse = soapConnection.call(soapMessage, url);
            SOAPBody soapBody = soapResponse.getSOAPBody();
            NodeList faultList = soapBody.getElementsByTagName("faultcode");
            NodeList resultList = soapBody.getElementsByTagName("Result");
            // Result processing;
            Boolean resultValue = true;
            if (resultList.getLength() > 0) {
                Element value = (Element) resultList.item(0);
                if ((value.getTextContent() != null) && (value.getTextContent().equals("false"))) {
                    resultValue = false;
                }
            }

            soapConnection.close();
answered