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);
}
});
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);
}
});
});
Related
I have an Office 365 extension that provides its own "Send" button which does some custom processing of the "draft" email and sends it through other means (ie not Office 365 Web). Since the email isn't sent by Outlook it never makes it to the sent folder (which makes sense). I would like to take that draft email and move it to the sent folder and remove the draft flag so it looks like it was sent by Outlook 365 Web.
var getMessageUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + itemId;
var data = JSON.stringify({ 'ToRecipients': [{ 'EmailAddress': { 'Address': 'sheprts#cox.net', 'Name': 'Katie Jordan' } }], 'IsRead': true, 'IsDraft': false });
$.ajax({
url: getMessageUrl,
type: 'PATCH',
dataType: 'json',
headers: { 'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json' },
data: data
})
})
.done(function (item) {
})
.fail(function (error) {
var err = ""
});
The request above works fine except the changing of the draft flag. If this isn't the solution what else can I do? I need to get a draft email into the sent folder as "Not" a draft.
Unfortunately you cannot create non-draft messages using the API.
Change your "other means" and set the "SaveInSentFolder" flag; or change to SMTP for your "other means".
So we are using Firebase to send notifications to our users on our iOS app. It works great in the console, but now we are looking to allow a few more people to send notifications, and we don't really want them signing into Firebase to do that. One solution we came up with is to put a form on our website and let them sign in and send notifications from there, but we can't get it to work. The code below is a stripped down version of what we have right now. It uses the cloud messaging API to send an HTTP POST request to a specific topic and Firebase responds with a message_id, however no message is delivered on any of the devices.
<!DOCTYPE html>
<html>
<body>
<input id="title"></input>
<input id="message"></input>
<button>Submit</button>
</body>
<script src="https://code.jquery.com/jquery-1.12.2.min.js" integrity="sha256-lZFHibXzMHo3GGeehn1hudTAP3Sc0uKXBXAzHX1sjtk=" crossorigin="anonymous"></script>
<script>
$("button").click(function () {
var title = $("#title").val();
var message = $("#message").val();
var param = {
"to" : "/topics/myTopic",
"content_available" : true,
"notification" : {
"title" : title,
"body" : message
}
};
$.ajax({
url: 'https://fcm.googleapis.com/fcm/send',
type: "POST",
headers: { 'Authorization': 'key=<myKey>', 'Content-Type': 'application/json' },
data: JSON.stringify(param),
success: function () {
alert("success");
},
error: function(error) {
alert("error: "+error);
}
});
});
</script>
</html>
Solution:
After we played around with it a bit more, we found that content_available should really be false in order to actually display a notification in our app. We also made sure to implement jQuery variables correctly. You can see our improved script for handling everything below.
$("button").click(function () {
// Grab the input values
$title = $("#title").val();
$message = $("#message").val();
// Verify that the message is not left empty
if ( $message.length < 2 ){
// Message is empty
return;
}
// Create the JSON object
var paramaters = {
"to" : "/topics/test",
"content_available" : false,
"notification" : {
"title" : $title,
"body" : $message
}
};
// Send request
$.ajax({
url: 'https://fcm.googleapis.com/fcm/send',
type: "POST",
headers: { 'Authorization': 'key=$key', 'Content-Type': 'application/json' },
data: JSON.stringify(paramaters),
success: function (e) {
// Process succeeded
console.log(e);
},
error: function(error) {
// Display error message
}
});
});
We also made sure that our server keys were not included directly in our code as Frank mentioned in his comment. Everything now works and we are successfully receiving notifications.
When I want use Ajax to update article in console I got: "Failed to load resource: the server responded with a status of 405 (Method Not Allowed)"
my jQuery code:
setInterval(function()
{
tinyMCE.triggerSave();
var url = window.location.href;
var article_id = /id\.([\d]+)/.exec(url)[1];
$.ajax(
{
url: '//' + $(location).attr('host') + '/cms/article/addDraft/' + article_id,
type: 'POST',
data: new FormData($('form.formAjax')[0]),
processData: false,
contentType: false,
success: function(response)
{
var alert = 'alert alert-warning';
$('.alert-box')
.hide()
.addClass(alert)
.html(response)
.slideDown(1500);
setTimeout(function() { $('.alert-box').slideUp(1500) }, 600);
}
});
},
6000);
and php:
// ADD ARTICLE DRAFT
public function addDraft($article_id)
{
Articles::where('id', '=', $article_id)->update(['title' => Request::Input('title'),
'description' => Request::Input('description')]);
return response(trans('errors.positive'), 200);
}
Thanks for help :)
look in your routes.php file.
Your POST request has to corespond with Route::post(), not with Route::get().
So I am trying to setup a PhoneGap IOS and Parse.com Push notification app. I am using this plugin https://github.com/mgcrea/cordova-push-notification to register the device with apple and get back the device token. Now I need to save that data to the Installition class on my Parse. Problem is when I do a save it creates a new installation class.
var Installation = Parse.Object.extend("Installation");
var installation = new Installation();
installation.save({badge: status.pushBadge, deviceToken: status.deviceToken, deviceType: status.type, installationId: appID}, {
success: function(response){
alert("seccuees " + response);
},
error: function(error){
alert("error " + error.message);
}
});
I have also tried using a ajax call to the rest api and no go..
$.ajax({
type: 'GET',
headers: {'X-Parse-Application-Id':'miid','X-Parse-Rest-API-Key':'myid'},
url: "https://api.parse.com/1/installations",
data: {"deviceType": "ios", "deviceToken": "01234567890123456789", "channels": [""]},
contentType: "application/json",
success: function(response){
alert("Success " + response);
},
error: function(error){
alert("Error " + error.message);
}
});
Dont use "Installation" class. It will just create a new Installation object. To create Parse Installation object for Push notification, use "_Installation". Following is the way to do it.
var installation = new Parse.Object("_Installation");;
installation.save({ channels: ['channelName'], deviceType: "android", installationId: id}, {
success: function(response){
alert("success " + response);
},
error: function(error){
alert("error " + error.message);
}
});
Make sure type is 'POST' not 'Get' if you are updating data
$.ajax({
type: 'POST', // <============
headers: {'X-Parse-Application-Id':'miid','X-Parse-Rest-API-Key':'myid'},
url: "https://api.parse.com/1/installations",
data: {"deviceType": "ios", "deviceToken": "01234567890123456789", "channels": [""]},
contentType: "application/json",
success: function(response){
alert("Success " + response);
},
error: function(error){
alert("Error " + error.message);
}
});
Also could you provide more details on the error that is returned
I have an ASP.Net MVC 3 application that uses a jQuery .ajax call to POST to a server-side controller action as follows
Client-Side jQuery call:
//Page the server
$.ajax({
url: '/Home/Call_Abort',
type: 'POST',
data: "{ 'op_id': '" + ajaxOPID + "', 'statMsg': '" + ajaxStatMsg + "'}",
contentType: 'application/json; charset=utf-8',
success: function (data) {
window.location.href = data.redirectUrl;
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Error while paging the server to abort. Reported error: '" + xhr.responseText + "'.");
}
});
Server-controller action:
[HttpPost]
public JsonResult Call_Abort(string op_id, string statMsg)
{
return Json(new
{
redirectUrl = Url.Action("Operator_Home", "Home", new { op_id = op_id, status = statMsg }),
isRedirect = true
});
}
The return URL is supposed to redirect the user to a different View (i.e. the Operator_Home View). This works on my local development PC, routing to the Operator_Home View as expected, but when I run it on my Development Web Server (Server 2008 with IIS 7) to test, I get the following 404 error page thrown as the xhr.responseText result in the .ajax call above.
It seems like what's happening is instead of redirecting to the View I specify in the redirectURL (i.e. Operator_Home), it seems to think the Call_Abort controller action is supposed to return a Call_Abort View, since no such View exists the error below gets tossed. But why would this happen on the Web Server and not on my local PC running the Visual Studio dev server? Is there some setting I need to make adjust for my application on IIS in order to get it to behave as it does on my development machine. My understanding of MVC routing isn't clear enough to know why this is occurring. Any help or insight is appreciated.
UPDATE
My apologies, there are several servers I'm working with at my place of employemnt, I was referencing the wrong web server. The server I'm running this on is Server 2008 with IIS7
The error turned out to be an issue with the URL in tha .Ajax call I modified the URL as follows:
//Page the server
var abortURL = window.location.origin + '/myApp/Home/Call_Abort';
$.ajax({
url: abortURL,
type: 'POST',
data: "{ 'op_id': '" + ajaxOPID + "', 'statMsg': '" + ajaxStatMsg + "'}",
contentType: 'application/json; charset=utf-8',
success: function (data) {
window.location.href = data.redirectUrl;
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Error while paging the server to abort. Reported error: '" + xhr.responseText + "'.");
}
});
This resolved the issue and allowed jQuery to complete the POST.