I am using EWS in meteor js app and I am using lather to compose the soap request.
I would like to get all meetings form Exchange, and I need meeting's organiser email address (SMTP), but it always retreive x500 addrress like:
/O=ABCD/OU=EXCHANGE ADMINISTRATIVE GROUP (ABCDEFGH)/CN=RECIPIENTS/CN=ABCD00000"
I have searched for a solution and found this:
NameResolutionCollection coll = service.ResolveName("/O=ABCD/OU=EXCHANGE ADMINISTRATIVE GROUP (ABCDEFGH)/CN=RECIPIENTS/CN=ABCD00000", ResolveNameSearchLocation.DirectoryOnly,true)
But I am not using C#, how can this be done in technology free fashion.
A ResolveName SOAP request should look something like https://msdn.microsoft.com/en-us/library/office/aa563518(v=exchg.150).aspx eg
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
</soap:Header>
<soap:Body>
<m:ResolveNames ReturnFullContactData="true" SearchScope="ActiveDirectoryContacts">
<m:UnresolvedEntry>test</m:UnresolvedEntry>
</m:ResolveNames>
</soap:Body>
</soap:Envelope>
So in Lather based on the other example on that page something like
var lather = require('lather');
var resolveName = {
'm:ResolveNames' : {
attributes : [
{ ReturnFullContactData : 'true' },
{ SearchScope : 'ActiveDirectoryContacts' },
],
'm:UnresolvedEntry' : '/O=ABCD/OU=EXCHANGE ADMINISTRATIVE GROUP (ABCDEFGH)/CN=RECIPIENTS/CN=ABCD00000',
},
};
lather.up({
body : resolveName,
headers : {
Authorization : lather.basicAuth(exchangeUserName, exchangePassword),
},
additionalNamespaces : [
'xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"',
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"',
],
method : 'POST',
url : 'https://outlook.office365.com/EWS/Exchange.asmx',
}, function(error, res, body) {
...
});
Should work (but maybe some changes are required)
Cheers
Glen
Related
I have a soap request that needs to look like this, with the 'user:' qualifier ONLY pertaining to the 'getTopQuestions' tag. Here is what the request SHOULD look like:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<user:getTopQuestions>
<interfaceId>4</interfaceId>
<numberOfQuestions>10</numberOfQuestions>
</user:getTopQuestions>
</soap:Body>
</soap:Envelope>
However, my request looks like this. As you can see, the 'user:' namespace qualifier is attached to the children tags of the parent 'user:getTopQuestions'
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<user:getTopQuestions>
<user:interfaceId>4</user:interfaceId>
<user:numberOfQuestions>10</user:numberOfQuestions>
</user:getTopQuestions>
</soap:Body>
</soap:Envelope>
How do I get the 'user:' namespace qualifier off of the child tags 'interfaceId' and 'numberOfQuestions'?
Here is my request:
$.soap({
url,
method: options.method,
data: options.data || {},
success: soapResponse => {
let responseContent = `${options.method}Response`;
let body = 'Body';
let data = soapResponse.toJSON();
if (data['soap:Body']) {
responseContent = `ns1:${responseContent}`;
body = `soap:${body}`;
}
data = data[body][responseContent];
deferred.resolve(data);
},
error: SOAPResponse => {
deferred.reject(SOAPResponse);
},
namespaceQualifier: "user:",
envAttributes: {
'xmlns:user': '/com/intelliresponse/search/user'
},
SOAPAction: " "
});
Can you remove the ":" from the namespaceQualifier as suggested here
https://github.com/zachofalltrades/jquery.soap
use namespaceQualifier: 'myns', // used as namespace prefix for all
instead of namespaceQualifier: ':myns' //with a colon
I am using json mapping to match the request. The request coming as content-type application/x-www-form-urlencoded which means as a Key=value pair and the value contains xml data. For example:
REQUEST=<?xml version="1.0" encoding="UTF-8"?>
<n:request xmlns:n="schema uri" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="schema location">
<header userId="userId" password="password" requesterId="123" version="100" language="de">
<product>xxx</product>
</header>
<subject>
<party externalIdentifier="1">
<address externalIdentifier="11">
<person>
<firstName>rinku</firstName>
<lastName>chy</lastName>
<birthDate>1973-12-10</birthDate>
</person>
<street>street</street>
<number>12</number>
<countryCode>de</countryCode>
<zipCode>123</zipCode>
<city>city</city>
</address>
</party>
</subject>
</n:request>
The purpose is to find the product name and the person's name. I have tried both xpath as well as query parameters expression to match the request as stated in http://wiremock.org/docs/request-matching/. But couldn't manage to get a solution yet.For example
{
"request": {
"method": "POST",
"urlPattern": "/mock.*",
"queryParameters": {
"product": {
"matches": "xxx"
}
},
// tried both seperately
"bodyPatterns": [
{
"matchesXPath": "//*[local-name()='request']/*[local-name()='header']/*[local-name()='product'][text()='xxx']"
}
]
},
"response": {
"status": 200,
"bodyFileName": "response.xml",
"headers": {
"Content-Type": "text/xml; charset=UTF-8",
"Content-Location": "response.xml"
}
}
}
Always getting the same error "[WireMock] (qtp2017957857-34) Warning: failed to parse the XML document. Reason: Content is not allowed in prolog.
Can anyone have a clue how to match such a request?
I found the solution. There is an option to intercept and modify requests. Visit -> http://wiremock.org/docs/extending-wiremock/ in the section "Intercepting and modifying requests".
public class RequestFilter extends StubRequestFilter {
#Override
public RequestFilterAction filter(Request request) {
// removed "REQUEST=" from request body
Request modifyRequest = RequestWrapper.create()
.transformBody(requestBody -> Body.fromOneOf(null, requestBody.asString().substring(8)), null, null))
.wrap(request);
return RequestFilterAction.continueWith(modifyRequest);
}
#Override
public String getName() {
return "my-request-filter";
}}
I'm trying to call HPQC API to get some reports but I'm not able to get the QCsession cookie when I call /qcbin/rest/site-session. I successfully authenticated with /qcbin/authentication-point/authenticate but I'm stuck in the next phase.
Not that I can use the API without any trouble with Postman, but my Google script doesn't work.
Here's a look at the call I'm doing :
var headers = { "Accept":"application/xml",
"Content-Type":"application/xml",
"method": "POST",
"headers" : {"Authorization": digestfull },
"muteHttpExceptions": true
};
var resp = UrlFetchApp.fetch(url,headers);
var cookie = resp.getAllHeaders();//['Set-Cookie'];//.split(';')[0].toString();
Logger.log(cookie);
//Get session cookie
param = "/hp/rest/site-session";
var url2 = hpqc + param + api_key;
var payload = "<session-parameters><client-type>REST Client</client-type></session-parameters>";
var headers2 = { "Accept":"application/json",
"Content-Type":"application/xml",
"method": "POST",
"muteHttpExceptions" : true,
"cookie" : cookie,
"body" : payload
};
resp = UrlFetchApp.fetch(url2,headers2);
The first call works fine, but the second gives me the following response :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 401 Authentication failed. Browser based integrations - to login append '?login-form-required=y' to the url you tried to access.</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /qcbin/rest/site-session. Reason:
<pre> Authentication failed. Browser based integrations - to login append '?login-form-required=y' to the url you tried to access.</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
It seems that the cookies aren't correctly sent.
Can you please help me find what is wrong with my code ? I'm sorry if it's too obvious, I'm learning to use google script.
Thank you
I changed the following code
var payload = "<session-parameters><client-type>REST Client</client-type></session-parameters>";
var headers2 = { "Accept":"application/json",
"Content-Type":"application/xml",
"method": "POST",
"muteHttpExceptions" : true,
"cookie" : cookie,
"body" : payload
};
with this and it worked
var payload = "<session-parameters><client-type>REST Client</client-type></session-parameters>";
var headers = {// "accept":"application/json",
//"contentType":"application/json",
"method": "POST",
"muteHttpExceptions" : true,
"headers" : {
"Content-type" : "application/xml",
"Accept" : "application/json",
"Cookie" : cookie
},
"payload" : payload
};
Thank you TheMaster for giving me the hint !!
I am using smartface.io to call a soap web service. My code is as below. when I call it returns a error says "Server Error" But when I call it from browser it works well.
var requestString =
'' +
'' +
'' +
'' +
'admin#borapay.com' +
'Admin#123456<>' +
'' +
'' +
'';
var getRate = new SMF.Net.WebClient({
URL : "http://172.98.72.148/borapay/WebServices/CustomerServices.asmx",
httpMethod : "POST",
requestHeaders : [
"Content-Type: text/xml;charset=UTF-8",
"SOAPAction: http://tempuri.org/UserLogin"
],
onSyndicationSuccess : function (e) {
},
onServerError : function (e) {
alert("onServerError");
},
requestString : requestString,
responseHandling : SMF.Net.ResponseHandling.forceText,
timeoutInterval : 120
});
getRate.run()
Your request string seems wrong, it should be full envelope like;
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bora="http://bora-pay.com/">
<soapenv:Header/>
<soapenv:Body>
<bora:UserLogin>
<!--Optional:-->
<bora:userName>admin#borapay.com</bora:userName>
<!--Optional:-->
<bora:password>Admin#123456<></bora:password>
</bora:UserLogin>
</soapenv:Body>
</soapenv:Envelope>
But you need to convert that as a Java Script string.
So I am trying to communicate with the freshbooks api by making the sample request detailed on the developers page of freshbooks (http://developers.freshbooks.com/). We are doing token-based authentication as opposed to using OAuth.
I have my code logging the responses to my requests in a spreadsheet. The responses it has been logging are as follows:
<?xml version="1.0" encoding="utf-8"?>
<response xmlns="http://www.freshbooks.com/api/" status="fail">
<error>Authentication failed.</error>
<code>20010</code>
</response>
I have been able to authenticate when using a curl command in console, but not when running the script. Below is the code I used. Left out the logging to spreadsheet part and our specific url and authToken:
// Sample function to call into an API using basic HTTP auth
function freshbooksTest () {
var url = ;
var authToken = ;
var unamepass =authToken+":X";
var digestfull = "Basic "+unamepass;
var payload = '<request method="system.current"></request>';
var options =
{
"method" : "post",
"muteHttpExceptions": true,
"headers" : {"Authorization": digestfull},
"payload" : payload
};
var response = UrlFetchApp.fetch(url, options);
var xml = response.getContentText();
}
I have checked out threads where people are having similar problems, but the solutions were either not applicable to my situation, or have already been tried. Any suggestions are welcome.
Not specifically familiar with UrlFetchApp, but if it doesn't do it for you, you'll need to Base64 encode digestfull before you send it in the header.
Looks like you need to base 64 encode your auth token. Code should look like this:
function freshbooksTest () {
var url = ;
var authToken = ;
var unamepass = authToken+":X";
var digestfull = "Basic "+ Utilities.base64Encode(unamepass);
var payload = '<request method="system.current"></request>';
var options =
{
"method" : "post",
"muteHttpExceptions": true,
"headers" : {"Authorization": digestfull},
"payload" : payload
};
var response = UrlFetchApp.fetch(url, options);
var xml = response.getContentText();
}