Call web service in Node js: Unhandled rejection Error: Invalid WSDL - ios

The following Node.js code gives me error "Unhandled rejection Error: Invalid WSDL":
// Purpose: via node platform to access another system from my company
// This is the project url to get web service, already working on soapUI
var url = "https://w3(intranet-link)/webservices/ws_GetUserData.wss?wsdl";
var args = {
msg:"connecting!"
};
//define project access
var userid='';
var password='';
soap.createClientAsync(url).then((client) => {
//add project access to logon to url
client.setSecurity(new soap.BasicAuthSecurity(userid, password));
return client.MyFunctionAsync(args);
}).then((result) => {
console.log(result);
});
How can I fix this problem? Thank you!

Related

How can I access a Teams user's email address?

I'm trying to build a Microsoft Teams integration for an app, but I'm having some trouble getting a user's email address.
I used the Microsoft Teams extension for VS Code to scaffold a basic app. I'm using the BotFramework v4 (NodeJS) on my server. I'm able to receive requests from Teams and respond to them as well.
To get an user's email address, I am using the TeamsInfo.getMember(context, id) method, where the id is obtained from context.activity.from object. Unfortunately, calling this method results in a RestError: Unknown with a status code of 400.
I'm not sure what I'm missing here. My app is registered with the Azure Active Directory and has the User.Read.All permission. Am I missing something here?
Any help would be appreciated!
For some context, I'm trying to build a Messaging Extension Action Command.
Code:
import {
TurnContext,
TeamsActivityHandler,
CardFactory,
MessagingExtensionAction,
TeamsInfo,
} from 'botbuilder';
export default class TeamsMessagingExtensionsActionBot extends TeamsActivityHandler {
constructor() {
super();
}
// #ts-ignore
handleTeamsMessagingExtensionSubmitAction(
context: TurnContext,
action: MessagingExtensionAction,
) {
switch (action.commandId) {
case 'someCommand':
return handleCommand(context, action);
default:
throw new Error('NotImplemented');
}
}
}
async function handleCommand(
context: TurnContext,
action: MessagingExtensionAction,
) {
const card = CardFactory.heroCard(
'Some Command',
'We have received your command!',
);
const user = await TeamsInfo.getMember(context, context.activity.from.id);
console.log('User:', user);
const attachment = {
contentType: card.contentType,
content: card.content,
preview: card,
};
return {
composeExtension: {
type: 'result',
attachmentLayout: 'list',
attachments: [attachment],
},
};
}
This is the error I get when calling TeamsInfo.getMember(): JSON

SAPUI5: OData V2 returns error "The Data Services Request could not be understood due to malformed syntax"

I'm trying to use OData V2 as suggested in this comment.
The issue is whenever I use sap.ui.model.odata.v2.ODataModel rather than the deprecated sap.ui.model.odata.ODataModel, I get this error from SAP Gateway Error Log
The Data Services Request could not be understood due to malformed syntax
Controller:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/odata/v2/ODataModel",
// ...,
], function(Controller, ODataModel/*, ...*/) {
"use strict";
Here is when I called OData V2:
onPressButton1: function(){
var vEntityURL = "/CustomerSet(ID='000')";
var sServiceUrl = "/Customers_SRV/";
var oServiceModel = new ODataModel(sServiceUrl, true);
oServiceModel.read(vEntityURL, {
success: function(oData) {
// ...
}
});
},
This is batch error.
Your entity set is not supporting batch calls.
Make sure that allows batch call or set use batch - false as below,
oServiceModel.setUseBatch(false);
This will work for you.

How to get an ACS app-only access token for Project Online

I'm trying to get an AppOnly access token for use in the Authorization Bearer header of my request to a REST endpoint in Project Online (SharePoint). Following is a snippet of the code that I was using to retrieve the access token.
private OAuth2AccessTokenResponse GetAccessTokenResponse()
{
var realm = TokenHelper.GetRealmFromTargetUrl([[our_site_url]]);
var resource = $"00000003-0000-0ff1-ce00-000000000000/[[our_site_authority]]#{realm}";
var formattedClientId = $"{ClientId}#{realm}";
var oauth2Request = OAuth2MessageFactory.CreateAccessTokenRequestWithClientCredentials(
formattedClientId,
ClientSecret,
resource);
oauth2Request.Resource = resource;
try
{
var client = new OAuth2S2SClient();
var stsUrl = TokenHelper.AcsMetadataParser.GetStsUrl(realm);
var response = client.Issue(stsUrl, oauth2Request) as OAuth2AccessTokenResponse;
var accessToken = response.AccessToken;
}
catch (WebException wex)
{
using (var sr = new StreamReader(wex.Response.GetResponseStream()))
{
var responseText = sr.ReadToEnd();
throw new WebException(wex.Message + " - " + responseText, wex);
}
}
}
I keep getting 403 Forbidden as the response from the server, even if I include site collection admin credentials with my request. Does anyone out there have any ideas?
After creating a support ticket with Microsoft to figure this out we eventually decided to move away from using app permissions for console application authorization.
Our workaround was to create SharePointOnlineCredentials object using a service account, and then get the Auth cookie from the credentials object to pass with our WebRequest. This solution came from scripts found here: https://github.com/OfficeDev/Project-REST-Basic-Operations

(401) Unauthorized calling https://api.twitter.com/oauth/access_token using tweetinvi

I started playing with tweetinvi to connect to twitter api. I keep getting "The remote server returned an error: (401) Unauthorized." error message when I call CredentialsCreator.GetCredentialsFromVerifierCode() after being redirected.
I added my phone to my account.
I made use the Consumer Key and Consumer Secret are the same.
I made use that my time is current
The callback url in app settings is http://127.zero.zero.1:53260/
I'm kinda of lost on what to do next.
This is the only code that I use:
protected void Page_Load( object sender, EventArgs e )
{
Tweetinvi.WebLogic.TemporaryCredentials applicationCredentials = (Tweetinvi.WebLogic.TemporaryCredentials)CredentialsCreator.GenerateApplicationCredentials( Properties.Settings.Default.TwitterConsumerKey, Properties.Settings.Default.TwitterConsumerSecret );
if (Request["oauth_token"] == null)
{
string url = CredentialsCreator.GetAuthorizationURLForCallback( applicationCredentials, "http://127.0.0.1:53260/twitter.aspx" );
Response.Redirect( url, false );
}
else
{
string verifierCode = Request["oauth_verifier"];
// error calling this code
var newCredentials = CredentialsCreator.GetCredentialsFromVerifierCode( verifierCode, applicationCredentials );
Console.WriteLine( "Access Token = {0}", newCredentials.AccessToken );
Console.WriteLine( "Access Token Secret = {0}", newCredentials.AccessTokenSecret );
}
}
Looks like you have everything correct. It might be the library you are using. Have you tried LinqToTwitter?
They have several examples you can test at http://linqtotwitter.codeplex.com/SourceControl/latest#ReadMe.txt. Just download their source files and you'll find Linq2TwitterDemos_WebForms project that you can text out.

simple Google Drive access with Dart

I am trying to read a basic text file(no authorization needed) from google drive with Dart. The code below returns a 400 Error. If the API_KEY is removed then a 403 error. I can input the file id into the Google get file reference page and it will return the metadata correctly.
Any Ideas would be great. Thanks
final url = "https://www.googleapis.com/drive/v2/files/FILE?key={API_KEY}";
var request = new HttpRequest();
request.on.loadEnd.add( (Event e)
{
if (request.status == 200)
{
var data = JSON.parse(request.responseText);
query("#file").text = data;
}
else
{
query("#file").text = "Error ${request.status}: ${request.statusText}";
}
});
request.open("GET", url);
request.send();
Your best bet is to use the drive_v2_api_client.
This can be done by setting up your google console apis with the following settings for localhost testing with DartEditor
Redirect URIs: http://127.0.0.1:3030/oauth2callback
JavaScript origins: http://127.0.0.1:3030
Then use the dart drive package drive_v2_api_client by putting the following depenencies in your pubspec.yaml file.
dependencies:
drive_v2_api_client:
git: git://github.com/Scarygami/dart_drive_v2_api_client.git
This example allows the client to get the fileid after the client has authenticated with the client id.
import 'dart:html';
import 'dart:json';
import "package:drive_v2_api_client/drive_v2_api_client.dart" as drivelib;
import "package:google_oauth2_client/google_oauth2_client.dart";
final CLIENT_ID = "<YOUR CLIENT ID FROM CONSOLE API>";
final SCOPES = [drivelib.Drive.DRIVE_FILE_SCOPE];
void main() {
var fileid = "1B_cGCNFjnK3dDriTMLsSS_zExfGFkQeewb3dcP4xSPg";
var auth = new OAuth2(CLIENT_ID, SCOPES);
var drive = new drivelib.Drive(auth);
drive.makeAuthRequests = true;
var loginButton = query("#login");
var output = query("#text");
loginButton.on.click.add((Event e) {
auth.login().then((token) {
output.appendHtml("Got Token ${token.type} ${token.data}<br><br>");
drive.files.get(fileid)
..then((data) {
output.appendHtml(data.toString());
});
});
});
}
You can find all the source code to a working example here https://gist.github.com/4588427

Resources