Calling a werbservice method to upload a file to the platform

Calling a werbservice method to upload a file to the platform

  
Hello folks.
 
I’m struggling to call a SOAP webservice from a mobile application to send a picture file (Base64 format) to the Outsystems platform, and I’m wondering if somebody can help me to identify what I’m doing wrong.
 
I have called several other webservices that are working properly, but none of them is related to sending a file to the platform, what evidences the problem comes from the fact that I’m not being able to manage the image file. When I call the webservice it doesn’t achieve the platform (I don’t receive anything in the debug) and I get the “Error 500 - Bad Request” as a response.
 
In case it ca be helpful, please find below the source code related to the webservice call.
 
Kind regards,
 
Rafael.

------------------------------------------
 
function receiptUpload(){  
    
    console.log(window.localStorage.getItem('imagem'));
        
         var productServiceUrl = "http://customcare.outsystemscloud.com/Zelum/WSZelumMobileIntegration.asmx?op=ReceiptUpload";
        
        var xmlmessage =  
            "<?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:Body>"+
                "<ReceiptUpload xmlns=\"http://www.outsystems.com\">"+
                  "<DeviceId>"+device.uuid+"</DeviceId>"+
                  "<ClientId>"+window.localStorage.getItem('clientid')+"</ClientId>"+
                  "<EntityId>"+244+"</EntityId>"+
        "<EntityPassword>"+window.localStorage.getItem('entitypassword')+"/EntityPassword>"+
                  "<ImageFile>"+window.localStorage.getItem('imagem')+"</ImageFile>"+
                  "<FileName>"+"notafiscal"+"</FileName>"+
                  "<ImageType>"+"jpeg"+"</ImageType>"+
                  "<Source>"+1+"</Source>"+
                "</ReceiptUpload>"+
              "</soap:Body>"+
            "</soap:Envelope>";
        
        console.log(xmlmessage);
    
        $.ajax({
            url: productServiceUrl,
            type: "POST",
            dataType: "xml",
            data: xmlmessage,
            complete: receiptReturn,
            contentType: "text/xml; charset=\"utf-8\""
        });
    }
 
Hello Rafael,

The Bad Request error is usually an HTTP error code 400, and not 500. This suggest that this is not a problem in the HTTP layer, but in the payload.

A rapid analysis, shows a missing '<' in the EntityPassword element. However, it's possible that something else is missing.

My suggestion is to use a tool like SOAP UI to test the web service, and get the request XML. You can then use this in your code.

Hopw this informaiton is helpful.

Cheers
Thanks a lot Miguel.

I'll check and work on your tips and let you know how they worked. I hope to come back with great news.

Cheers.