IBM MFP8 JavaScript Adapter connection timeout - ibm-mobilefirst

I am working with IBM MFP 8 JavaScript Adapters. As per the blogs or documentation below the request from Cordova Application.
var resourceRequest = new WLResourceRequest(
"adapters/LoginAdapter/validateLogin",
WLResourceRequest.POST
);
resourceRequest.sendFormParameters(params).then(
( response ) => {
resolve( response );
}, ( error ) => {
reject( error );
}
);
My problem here is, if I call the above method I get Connection Timeout. But if I pass the full url as below, it works.
var resourceRequest = new WLResourceRequest(
'http://xxx.xx.xx:9080/mfp/api' + "adapters/LoginAdapter/validateLogin",
WLResourceRequest.POST
);
resourceRequest.sendFormParameters(params).then(
( response ) => {
resolve( response );
}, ( error ) => {
reject( error );
}
);
Can anyone please confirm me if I have to pass the full URL for Adapter connection.
Thanks in advance.
Update :
When I try connecting to Adapters from IBM Mobile Simulator, I get the below error and connection is not established.
ERROR TypeError: Cannot read property 'getItem' of undefined
at __WLDAO.getItem (ibmmfpf-preview.js:8285)
at getItemFromMap (ibmmfpf-preview.js:4363)
at Object.__getCachedScopeByResource (ibmmfpf-preview.js:4410)
at __send (ibmmfpf-preview.js:6776)
at sendRequestAsync (ibmmfpf-preview.js:6660)
at WL.ResourceRequest.sendFormParameters (ibmmfpf-preview.js:6577)
at HomePage.webpackJsonp.191.HomePage.login (home.ts:21)
at Object.eval [as handleEvent] (HomePage.html:18)
at handleEvent (core.es5.js:11914)
at callWithDebugContext (core.es5.js:13206)
bound # ibmmfpf-preview.js:1334
View_HomePage_0 # HomePage.html:18
proxyClass # compiler.es5.js:14091
DebugContext_.logError # core.es5.js:13146
bound # ibmmfpf-preview.js:1334
ErrorHandler.handleError # core.es5.js:1144
IonicErrorHandler.handleError # ionic-error-handler.js:63
(anonymous) # core.es5.js:9410
(anonymous) # platform-browser.es5.js:2687
t.invokeTask # polyfills.js:3
onInvokeTask # core.es5.js:4140
t.invokeTask # polyfills.js:3
r.runTask # polyfills.js:3
invoke # polyfills.js:3
ibmmfpf-preview.js:1334 ERROR CONTEXT

Related

Inconsistent behavior from react-native-blob-util and fetch

I'm trying to call an API that takes an image and some data and returns json. I'm using react-native-blob-util with fetch. Problem is, the same code is working sometimes but failing in the next attempt - almost every alternate request is not submitting the data.
For replicating the issue, I have created the following code. It takes the **same** image file and parameters to make a fetch request.
(I am testing on android)
A button to call fetch function:
<TouchableOpacity
style={styles.btn}
onPress={() => {
MatchFace();
}}
>
<Text style={styles.btnText}>
Call API
</Text>
</TouchableOpacity>
And then this is the function that calls API:
const MatchFace = async () => {
setData([]);
ReactNativeBlobUtil.fetch(
'POST',
'url_for_the_api',
{
'Content-Type': 'multipart/form-data',
'Api-Key': 'api_key',
},[
{ name : 'image', filename : 'profile.jpg', type:'image/jpg', data: ReactNativeBlobUtil.wrap(decodeURIComponent('file:///storage/emulated/0/Download/profile.JPG'))},
{ name : 'album_id', data : '2'},
]
)
.then((response) => response.json())
.then((json) => setData(json))
.catch((error) => console.error(error))
.finally(() => console.log(data));
}
Part of log
**No response case**
G:\react-native\FaceAttendance\Screens\stackOverFlow.js:52 []
**Case where I get response**
G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:173 Stream Closed
registerWarning # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:173
console.warn # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:71
overrideMethod # G:\react-native\FaceAttendance\node_modules\react-devtools-core\dist\backend.js:2171
(anonymous) # G:\react-native\FaceAttendance\node_modules\react-native-blob-util\fetch.js:15
emit # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\vendor\emitter\_EventEmitter.js:149
__callFunction # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:419
(anonymous) # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:116
__guard # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:370
callFunctionReturnFlushedQueue # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:115
(anonymous) # RNDebuggerWorker.js:2
G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:173 Stream Closed
registerWarning # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:173
console.warn # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:71
overrideMethod # G:\react-native\FaceAttendance\node_modules\react-devtools-core\dist\backend.js:2171
(anonymous) # G:\react-native\FaceAttendance\node_modules\react-native-blob-util\fetch.js:15
emit # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\vendor\emitter\_EventEmitter.js:149
__callFunction # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:419
(anonymous) # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:116
__guard # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:370
callFunctionReturnFlushedQueue # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:115
(anonymous) # RNDebuggerWorker.js:2
G:\react-native\FaceAttendance\node_modules\react-native\Libraries\Core\ExceptionsManager.js:149 Error: unexpected end of stream
at G:\react-native\FaceAttendance\node_modules\react-native-blob-util\fetch.js:256
at MessageQueue.__invokeCallback (G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:465)
at G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:127
at MessageQueue.__guard (G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:370)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:126)
at RNDebuggerWorker.js:2
reactConsoleErrorHandler # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\Core\ExceptionsManager.js:149
registerError # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:204
console.error # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\LogBox\LogBox.js:67
overrideMethod # G:\react-native\FaceAttendance\node_modules\react-devtools-core\dist\backend.js:2171
eval # G:\react-native\FaceAttendance\Screens\stackOverFlow.js:51
tryCallOne # G:\react-native\FaceAttendance\node_modules\promise\setimmediate\core.js:37
(anonymous) # G:\react-native\FaceAttendance\node_modules\promise\setimmediate\core.js:123
(anonymous) # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:248
_callTimer # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:112
_callReactNativeMicrotasksPass # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:166
callReactNativeMicrotasks # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:418
__callReactNativeMicrotasks # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:393
(anonymous) # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135
__guard # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:370
flushedQueue # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134
invokeCallbackAndReturnFlushedQueue # G:\react-native\FaceAttendance\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:130
(anonymous) # RNDebuggerWorker.js:2
G:\react-native\FaceAttendance\Screens\stackOverFlow.js:52 {num_faces: 1, num_recognized_faces: 1, num_unknown_faces: 0, recognized_faces: Array(1), unknown_faces: Array(0)}
I'm sure that API is performing correctly (tested from test apps on react, php and also postman). I'm possibly doing something wrong with the react-native filesytem.
Oh, one more input - my application needs to call this API in every few seconds when the app runs.

asyncio stream vs synchronous stream in socket communication with a react native app

Objective is esp32 running micropython acts as a server while android app acts as a client. Before asyncio stream I am able to communicate successfully, but after switching to asyncio i fail to do so, only android app to esp32 is successful but app is failing to retrieve json output from server and I even tried text strings too . App side code remains unchanged for both synchronous/asyncio codes.
Desired output:
response = {
'error': 'invalid request',
'status': 'retry'
}
synchronous side:
conn.send('HTTP/1.1 200 OK\n')
conn.send('Content-Type: application/json\n')
conn.send('Connection: close\n\n')
conn.sendall(ujson.dumps(response ))
asyncio side:
swriter.write(ujson.dumps(response ))
await swriter.drain()
react native side:
fetch( 'http://192.168.0.110' )
.then(response => response.json())
.then((responseJson) => {
const data1 = responseJson;
console.log('getting data from fetch', data1)
setData({ data1 });
onConnectionMessage(data1);
})
synchronous way I was able to retrieve the json output sent from esp32 to android app(react native), but the same code using asyncio failed. What am I doing wrong?
sample asyncio server side code is:
import usocket as socket
import uasyncio as asyncio
import uselect as select
import ujson
from heartbeat import heartbeat # Optional LED flash
class Server:
def __init__(self, host='0.0.0.0', port=80, backlog=5, timeout=10):
self.host = host
self.port = port
self.backlog = backlog
self.timeout = timeout
async def run(self):
print('Awaiting client connection.')
self.cid = 0
asyncio.create_task(heartbeat(100))
self.server = await asyncio.start_server(self.run_client, self.host, self.port, self.backlog)
while True:
await asyncio.sleep(100)
async def run_client(self, sreader, swriter):
self.cid += 1
print('Got connection from client', self.cid)
try:
while True:
try:
res = await asyncio.wait_for(sreader.readline(), self.timeout)
except asyncio.TimeoutError:
res = b''
if res == b'':
raise OSError
print('Received {} from client {}'.format(ujson.loads(res.rstrip()), self.cid))
response = {
'error': 'invalid request',
'status': 'retry'
}
swriter.write(ujson.dumps(response))
await swriter.drain() # Echo back
except OSError:
pass
print('Client {} disconnect.'.format(self.cid))
await sreader.wait_closed()
print('Client {} socket closed.'.format(self.cid))
async def close(self):
print('Closing server')
self.server.close()
await self.server.wait_closed()
print('Server closed.')
server = Server()
try:
asyncio.run(server.run())
except KeyboardInterrupt:
print('Interrupted') # This mechanism doesn't work on Unix build.
finally:
asyncio.run(server.close())
_ = asyncio.new_event_loop()
got the error: asyncio.wait_for(sreader.readline(), self.timeout)------> changed to
asyncio.wait_for(sreader.read(2048), self.timeout). Now client is recieving json output immediately after closing the socket

Polymer 2.0 - Firebase Messaging Error - Uncaught (in promise) DOMException: Registration failed - push service error

I have a PWA app using Polymer 2.0 and firebase. Firebase messaging is throwing error.
Firebase v3.18.4
"polymer": "Polymer/polymer#^2.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0",
"polymerfire": "firebase/polymerfire#^2.2.0",
Uncaught (in promise) DOMException: Registration failed - push service error
Promise.then (async)
refreshToken # firebase-messaging.html:87
activateMessaging # firebase-messaging.html:125
activate # firebase-messaging.html:243
_bootstrapApp # firebase-messaging.html:259
runMethodEffect # property-effects.html:813
runEffectsForProperty # property-effects.html:159
runEffects # property-effects.html:125
_propertiesChanged # property-effects.html:1703
_flushProperties # properties-changed.html:338
_flushProperties # property-effects.html:1551
_invalidateProperties # property-effects.html:1523
_setProperty # property-effects.html:1508
Object.defineProperty.set # properties-changed.html:150
__appNameChanged # firebase-common-behavior.html:47
runObserverEffect # property-effects.html:214
runEffectsForProperty # property-effects.html:159
runEffects # property-effects.html:125
_propertiesChanged # property-effects.html:1703
_flushProperties # properties-changed.html:338
_flushProperties # property-effects.html:1551
ready # property-effects.html:1656
ready # element-mixin.html:546
ready # dir-mixin.html:140
ready # legacy-element-mixin.html:198
ready # class.html:232
ready # class.html:232
ready # class.html:232
_enableProperties # properties-changed.html:321
connectedCallback # properties-mixin.html:208
connectedCallback # element-mixin.html:532
connectedCallback # dir-mixin.html:150
connectedCallback # legacy-element-mixin.html:105
_attachDom # element-mixin.html:588
_readyClients # element-mixin.html:561
_flushClients # property-effects.html:1565
_propertiesChanged # property-effects.html:1699
_flushProperties # properties-changed.html:338
_flushProperties # property-effects.html:1551
ready # property-effects.html:1656
ready # element-mixin.html:546
ready # my-app.html:540
_enableProperties # properties-changed.html:321
connectedCallback # properties-mixin.html:208
connectedCallback # element-mixin.html:532
(anonymous) # my-app.html:849
The messaging doesn't work in Chrome Desktop - [Google Chrome is up to date
Version 66.0.3359.139 (Official Build) (64-bit)] as well as in Chrome Android - [Application version Chrome 66.0.3359.126
Code used
my-app.html (PolymerElement)
<script src="bower_components/firebase/firebase-app.js"></script>
<script src="bower_components/firebase/firebase-auth.js"></script>
<script src="bower_components/firebase/firebase-database.js">
</script>
<script src="bower_components/firebase/firebase-firestore.js">
</script>
<script src="bower_components/firebase/firebase-messaging.js">
</script>
<script src="bower_components/firebase/firebase-storage.js">
</script>
<firebase-app
auth-domain="[[configFirebase.authDomain]]"
database-url="[[configFirebase.databaseURL]]"
api-key="[[configFirebase.apiKey]]"
storage-bucket="[[configFirebase.storageBucket]]"
messaging-sender-id="[[configFirebase.messagingSenderId]]">
</firebase-app>
<firebase-auth
id="auth"
user="{{user}}"
signed-in="{{signedIn}}"
status-known="{{statusKnown}}"
on-error="_handleError">
</firebase-auth>
<firebase-messaging
id="messaging"
token="{{token}}"
on-message="handleMessage"
active="{{fcmActive}}"
status-known="{{fcmStatusKnown}}">
</firebase-messaging>
<firebase-document path="/users/[[user.uid]]/token" data=".
{{tokenDocVal}}">
</firebase-document>
class MyApp extends Polymer.Element {
static get is() { return 'my-app'; }
ready() {
this.addEventListener('request-fcm-permission',
this._requestFcmPermission);
super.ready();
}
_requestFcmPermission() {
var fcm = this.$.messaging;
var self = this;
if (this.user && !fcm.active) {
fcm.requestPermission()
.then(function(){
console.log('FCM permission granted');
console.log('[[token]] ->' + self.token);
self.tokenDocVal = self.token;
})
.catch(function(e){
console.warn('FCM permission blocked', e);
})
}
}
... other html code ....
And the
firebase-messaging-sw.js
importScripts('/bower_components/firebase/firebase-app.js');
importScripts('/bower_components/firebase/firebase-
messaging.js');
firebase.initializeApp({
'messagingSenderId': '<project-ms-id>'
});
var messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
console.log('[firebase-messaging-sw.js] Received background
message
', payload);
var notificationTitle = payload.notification.title;
var notificationOptions = {
body: payload.notification.body,
icon: '../images/fresh/android/android-launchericon-24-24.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
Manifest.json includes "gcm_sender_id": "103953800507",
Request help to resolve the issue. I have been on this issue for long and don't know why its happening and how to fix it.
I have also added a comment on the issue on GITHUB -
https://github.com/firebase/firebase-js-sdk/issues/152
Source code to replicate:
Git source code to replicate the issue
https://github.com/vinvantest/git_issue_firebase_login

HTTP post working on postman but not on Angular 2

I have a template which (click) triggets addUseCase():
import {Component} from "#angular/core";
import {DataService} from "../shared/data.service";
import {Config} from "../shared/strings";
import {Headers, Http} from "#angular/http";
#Component({
selector: "add",
styleUrls: ["add.component.scss"],
templateUrl: "add.component.html"
})
export class AddComponent {
public title: string;
public body: string;
constructor(private dataService: DataService,
private http: Http) {
this.title = "";
this.body = "";
}
public addUseCase() {
let url = Config.baseUrl + Config.case;
console.log("url", url); // --> http://localhost:3001/case
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let body = JSON.stringify({title:this.title})
this.http.post(url, body, {headers: headers}).map( res => console.log ("res", res), error => console.log("error", error));
}
}
After testing in Postman I get my node/express server correct response. But when I try to use angular HTTP to send I don't get any response at all, no error:
My postman works, but can't make http post of angular 2 work:
Update with errors:
this.http.post(url, body, {headers: headers})
.map(res => res.json()).subscribe(data => console.log(data)); //...errors if any
;
And the errors:
EXCEPTION: Unexpected token W in JSON at position 0ErrorHandler.handleError # core.umd.js:3462next # core.umd.js:6924schedulerFn # core.umd.js:6172SafeSubscriber.__tryOrUnsub # Subscriber.js:223SafeSubscriber.next # Subscriber.js:172Subscriber._next # Subscriber.js:125Subscriber.next # Subscriber.js:89Subject.next # Subject.js:55EventEmitter.emit # core.umd.js:6164onError # core.umd.js:6388onHandleError # core.umd.js:6263ZoneDelegate.handleError # zone.js:236Zone.runTask # zone.js:157ZoneTask.invoke # zone.js:335
core.umd.js:3467 ORIGINAL STACKTRACE:ErrorHandler.handleError # core.umd.js:3467next # core.umd.js:6924schedulerFn # core.umd.js:6172SafeSubscriber.__tryOrUnsub # Subscriber.js:223SafeSubscriber.next # Subscriber.js:172Subscriber._next # Subscriber.js:125Subscriber.next # Subscriber.js:89Subject.next # Subject.js:55EventEmitter.emit # core.umd.js:6164onError # core.umd.js:6388onHandleError # core.umd.js:6263ZoneDelegate.handleError # zone.js:236Zone.runTask # zone.js:157ZoneTask.invoke # zone.js:335
core.umd.js:3468 SyntaxError: Unexpected token W in JSON at position 0
at JSON.parse (<anonymous>)
at Function.Json.parse (http://localhost:3000/vendor.bundle.js:11272:59)
at Response.Body.json (http://localhost:3000/vendor.bundle.js:12250:30)
at MapSubscriber.project (http://localhost:3000/main.bundle.js:6202:47)
at MapSubscriber._next (http://localhost:3000/vendor.bundle.js:23914:36)
at MapSubscriber.Subscriber.next (http://localhost:3000/vendor.bundle.js:249:19)
at XMLHttpRequest.onLoad (http://localhost:3000/vendor.bundle.js:12581:43)
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:14882:36)
at Object.onInvokeTask (http://localhost:3000/vendor.bundle.js:6930:42)
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:14881:41)
------------- Elapsed: 16 ms; At: Thu Oct 27 2016 08:06:32 GMT-0500 (COT) -------------
at Object.onScheduleTask (http://localhost:3000/polyfills.bundle.js:14537:19)
at ZoneDelegate.scheduleTask (http://localhost:3000/polyfills.bundle.js:14859:50)
at Zone.scheduleEventTask (http://localhost:3000/polyfills.bundle.js:14791:40)
at zoneAwareAddListener (http://localhost:3000/polyfills.bundle.js:15441:15)
at XMLHttpRequest.addEventListener (eval at createNamedFn (http://localhost:3000/polyfills.bundle.js:15544:18), <anonymous>:3:43)
at Observable._subscribe (http://localhost:3000/vendor.bundle.js:12624:23)
at Observable.subscribe (http://localhost:3000/vendor.bundle.js:70:28)
at Observable._subscribe (http://localhost:3000/vendor.bundle.js:128:29)ErrorHandler.handleError # core.umd.js:3468next # core.umd.js:6924schedulerFn # core.umd.js:6172SafeSubscriber.__tryOrUnsub # Subscriber.js:223SafeSubscriber.next # Subscriber.js:172Subscriber._next # Subscriber.js:125Subscriber.next # Subscriber.js:89Subject.next # Subject.js:55EventEmitter.emit # core.umd.js:6164onError # core.umd.js:6388onHandleError # core.umd.js:6263ZoneDelegate.handleError # zone.js:236Zone.runTask # zone.js:157ZoneTask.invoke # zone.js:335
http.umd.js:188 Uncaught SyntaxError: Unexpected token W in JSON at position 0(…)Json.parse # http.umd.js:188Body.json # http.umd.js:1166(anonymous function) # add.component.ts:34MapSubscriber._next # map.js:77Subscriber.next # Subscriber.js:89onLoad # http.umd.js:1497ZoneDelegate.invokeTask # zone.js:265onInvokeTask # core.umd.js:6233ZoneDelegate.invokeTask # zone.js:264Zone.runTask # zone.js:154ZoneTask.invoke # zone.js:335
You never subscribed to the Observable. No request will be made until you do so
this.http.post(url, body, {headers: headers})
.map(res => res.text()).subscribe(data => console.log(data));

Savon 2.11.1 set soap header after client is instantiated Rails + SSRS

I'm trying to integrate my rails app with a Sql Server Reports Services (SSRS) using Savon 2.11.1. I'm using the ReportServicesExecution2005 WSDL. The problem I have is that I have to add a session_id to the soap header after the client has been instantiated. This is because the session_id is generated by SSRS after the client makes a call to load_report.
client = Savon.client(wsdl: "https://somewsdl.asmx?wsdl", basic_auth: ["user", "pass"])
this call returns the session_id in the response:
response = client.call(:load_report, message: {report: "path/to/report"} )
the soap header needs to contain the session_id in the client when this call is made:
client.call(:set_execution_parameters, message: { report: "path/to/report", parameters: params } )
Tried this but it didn't work:
client.call(:set_execution_parameters, soap_header: {"session_id" => #session_id}, message: { report: "path/to/report", parameters: params } )
I get the following error:
(soap:Client) The session identifier is missing. A session identifier
is required for this operation. --->
Microsoft.ReportingServices.Diagnostics.Utilities.MissingSessionIdException:
The session identifier is missing. A session identifier is required
for this operation.
Thanks for the help an advance.
You should use the soap_header hash to pass session id like
response = client.call(:set_execution_parameters, :soap_header => { :session_id => sid })
Cheers
The solution I found(while clunky) was to create a new client via Savon and pass the existing client values plus the new execution_id/session_Id into the constructor. This did the trick. Code example below.
Initial Savon Client:
#exeClient = Savon.client(wsdl: "some_wsdl.asmx?wsdl", basic_auth: ["user", "pass"],
convert_request_keys_to: :camelcase, soap_header: {"execution_id" => ""} )
call load_report to get execution_id:
#data = #exeClient.call(:load_report, message: {report: "/path/to/report"} )
Access execution_id:
#report = #data.to_hash
#execution_id = #report[:load_report_response][:execution_info][:execution_id]
Create new client that has access to run the report via the execution_id:
#newClient = Savon.client(wsdl: "/path/to/report/wsdl", basic_auth: ["user", "pass"],
:soap_header => {:"tns:TrustedUserHeader" => {"tns:UserName"=> "" , "tns:UserToken" => ""}, :"tns:ExecutionHeader" => {"tns:ExecutionID" => #execution_id}})
Create Params Hash:
param1 = { :Parameter_value =>{
:"Name" => "nameOfParam",
:"Value" => current_user.company_id
}
}
Call setExecutionParameters:
response = #newClient.call(:set_execution_parameters, message: { "Parameters" => param1} )
Now it works. Note that its important how you specify namespaces with Savon. If you don't do it correctly, the namespace will not be specified on some tags; which will make the soap call fail.