Parse.com to communicate with WSDL

心已入冬 提交于 2019-12-12 23:16:59

问题


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);
  }
});

回答1:


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);
        }
    });
});


来源:https://stackoverflow.com/questions/25140080/parse-com-to-communicate-with-wsdl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!