Search code examples
wsdlparse-platformandroid-ksoap2

Parse.com to communicate with WSDL


Is there any possibility to call "WSDL" method in cloud code ?

for example, there is a "WSDL" web service and i want to check if there is an new data in it and if there is i want to send push notification to user. I got the logic, but i could not find any information about "WSDL" in parse.com documentation.

this didn't help:

Parse.Cloud.httpRequest({
  url: 'https://services.rs.ge/WayBillService/WayBillService.asmx',
  params: {
    su : 'test1'
  },
  success: function(httpResponse) {
    console.log(httpResponse.text);
  },
  error: function(httpResponse) {
    console.error('Request failed with response code ' + httpResponse.status);
  }
});

Solution

  • Sure you can, now, first we need to get a few things straight.

    WSDL is just the definition of the services "Web Services Description Language"

    You are talking SOAP here "Simple Object Access Protocol"

    If you go to https://services.rs.ge/WayBillService/WayBillService.asmx in your browser, you will se a list of methods/SOAPActions that are available to you and if you click them, you will see an example of how to call the method.

    For example, get_server_time, https://services.rs.ge/WayBillService/WayBillService.asmx?op=get_server_time

    Example how to call get_server_time:

    Parse.Cloud.job('soap', function(request, status) {
        var Buffer = require('buffer').Buffer,
            buffer = new Buffer(
                '<?xml version="1.0" encoding="utf-8"?>' +
                '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">' +
                '   <soap12:Body>' +
                '       <get_server_time xmlns="http://tempuri.org/" />' +
                '   </soap12:Body>' +
                '</soap12:Envelope>'
            );
    
        Parse.Cloud.httpRequest({
            method: 'POST',
            url: 'https://services.rs.ge/WayBillService/WayBillService.asmx',
            headers: {
                'Content-Type': 'text/xml; charset=utf-8'
            },
            body: buffer,
            success: function(httpResponse) {
                status.success(httpResponse.text);
            },
            error: function(httpResponse) {
                status.error('Request failed with response code ' + httpResponse.status);
            }
        });
    });