Hi I am having a bit of trouble figuring out how I can access this web service: http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
Using the groovy Wslite library, seems to work fine with the depreciated Groovy Soap library but I am not allowed to use that.
The libraries are described here:
Groovy Soap Use
Groovy-Wslite
I am totally new to groovy and these technologies in general so forgive my ignorance.
Basically I want this code:
import groovy.swing.SwingBuilder
import groovy.net.soap.SoapClient
proxy = new SoapClient("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL")
def currency = ['USD', 'EUR', 'CAD', 'GBP', 'AUD']
def rate = 0.0
swing = new SwingBuilder()
refresh = swing.action(
name:'Refresh',
closure:this.&refreshText,
mnemonic:'R'
)
frame = swing.frame(title:'Currency Demo') {
panel {
label 'Currency rate from '
comboBox(id:'from', items:currency)
label ' to '
comboBox(id:'to', items:currency)
label ' is '
textField(id:'currency', columns:10, rate.toString())
button(text:'Go !', action:refresh)
}
}
frame.pack()
frame.show()
def refreshText(event) {
rate = proxy.ConversionRate(swing.from.getSelectedItem(), swing.to.getSelectedItem())
swing.currency.text = rate
}
Converted to work with the groovy-wslite library and I cant get it to work no matter what I do.
Here is the Wslite library again.
wslite library
Any help is greatly appreciated.
I find it helpful to use a tool like soapUI first to figure out what request a service is expecting. From there it's a matter of using the markup builder to build that request. The following should work from the groovyConsole:
#Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.8.0')
import wslite.soap.*
def client = new SOAPClient('http://www.webservicex.net/CurrencyConvertor.asmx')
def response = client.send(SOAPAction: 'http://www.webserviceX.NET/ConversionRate') {
body {
ConversionRate( xmlns: 'http://www.webserviceX.NET/') {
FromCurrency('GBP')
ToCurrency('USD')
}
}
}
assert response
assert 200 == response.httpResponse.statusCode
println response.ConversionRateResponse.ConversionRateResult.text()
Related
I Created a android app in which if a press a button and value changes in Firebase database (0/1) , i want to do this using google assistant, please help me out, i searched out but didn't found any relevant guide please help me out
The code to do this is fairly straightforward - in your webhook fulfillment you'll need a Firebase database object, which I call fbdb below. In your Intent handler, you'll get a reference to the location you want to change and make the change.
In Javascript, this might look something like this:
app.intent('value.update', conv => {
var newValue = conv.prameters.value;
var ref = fbdb.ref('path/to/value');
return ref.set(newValue)
.then(result => {
return conv.ask(`Ok, I've set it to ${newValue}, what do you want to do now?`);
})
.catch(err => {
console.error( err );
return conv.close('I had a problem with the database. Try again later.');
});
return
});
The real problem you have is what user you want to use to do the update. You can do this with an admin-level connection, which can give you broad access beyond what your security rules allow. Consult the authentication guides and be careful.
I am actually working on a project using Dialogflow webhook and integrated Firebase database. To make this posible you have to use the fulfilment on JSON format ( you cant call firebasedatabase in the way you are doing)
Here is an example to call firebase database and display a simple text on a function.
First you have to take the variable from the json.. its something loike this (on my case, it depends on your Entity Name, in my case it was "tema")
var concepto = request.body.queryResult.parameters.tema;
and then in your function:
'Sample': () => {
db.child(variable).child("DESCRIP").once('value', snap => {
var descript = snap.val(); //firebasedata
let responseToUser = {
"fulfillmentMessages": [
{ //RESPONSE FOR WEB PLATFORM===================================
'platform': 'PLATFORM_UNSPECIFIED',
"text": {
"text": [
"Esta es una respuesta por escritura de PLATFORM_UNSPECIFIED" + descript;
]
},
}
]
}
sendResponse(responseToUser); // Send simple response to user
});
},
these are links to format your json:
Para formatear JSON:
A) https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/Shared.Types/Platform
B) https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/Shared.Types/Message#Text
And finally this is a sample that helped a lot!!
https://www.youtube.com/watch?v=FuKPQJoHJ_g
Nice day!
after searching out i find guide which can help on this :
we need to first create chat bot on dialogflow/ api.pi
Then need to train our bot and need to use webhook as fullfillment in
response.
Now we need to setup firebase-tools for sending reply and doing
changes in firebase database.
At last we need to integrate dialogflow with google assistant using google-actions
Here is my sample code i used :
`var admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp(functions.config().firebase);
var database = admin.database();
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.hello = functions.https.onRequest((request, response) => {
let params = request.body.result.parameters;
database.ref().set(params);
response.send({
speech: "Light controlled successfully"
});
});`
I need to send the image file using multipart request from Lightroom to my local web service using Lua language.
I have tested using sending headers also but not working...
I have created a function :
function testupload(filepath) --created inside LrTasks
local url = "http://localhosturl"
local mycontent = {
{
name = "lightroom_message",
value = "sent from lightroom plugin multiparta"
},
{
name = 'file',
filePath = filepath,
fileName = LrPathUtils.leafName(filepath),
contentType = 'image/jpeg'
--contentType = 'multipart/form-data'
}
}
local response, headers = LrHttp.postMultipart(url, mycontent)
end
But my web service is not getting called properly and I am using LrHttp.postMultipart() method to do so..
If I am sending just this param to web service (then working fine):
{
name = "lightroom_message",
value = "sent from lightroom plugin multiparta"
}
but when I include my file payload then its not working using pure Lua implementation.
Everything was correct but just a technical mistake...I was trying to call the testupload() function from inside LRtasks..but we dont need to call it in separate task and the function works perfect
I am New to blackberry Develipment.I am developing using Momentics IDE. Now I am working on Soap webservice integration. Now my webservice function call is working. I am getting response also. My webservice response is like,
<SignupResponse xmlns="http://shidhints.com/">
<SignupResult>
<Success>boolean</Success>
<ErrorOnFailure>string</ErrorOnFailure>
<Token>string</Token>
<NumberofReferral>int</NumberofReferral>
<ListEmails>
<string>string</string>
<string>string</string>
</ListEmails>
</SignupResult>
</SignupResponse>
While parese the responce, Now I can parse and get the Token, NumberofReferral But I cannot parse the ListEmails object. How I can parse this ListEmails. I am doing like this.
m_Token = responseValue["Token"].value().toString();
m_NumberofReferral = responseValue["NumberofReferral"].value().toString();
QVariantList listObj = responseValue["ListEmails"].value().toList();
Now I want to parse listObj How i can do that,
responseValue["ListEmails"]
That element contains multiple values, so you'll get a QVariant wrapping a QVariantList .
More info:
http://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/working_with_xml.html
http://developer.blackberry.com/native/reference/cascades/bb__data__xmldataaccess.html
I have resolved it using
QtSoapArray &m_Emails1 = (QtSoapArray &) responseValue["ListEmails"];
for (int var = 0; var < m_Emails1.count(); ++var) {
qDebug() << "Email: "+ m_Emails1[var].toString();
}
I was trying to use angular dart with websockets/server sent events and could not find any documentation/examples (there are some for angularJS but that seems very different for such things). A few things I tried also did not work.
Does anyone know how to do this?
Here is one version of what I tried and the error:
#NgController (
selector: "ACdistribution",
publishAs : "dstbn")
class ACDstbnController{
List <WtdPres> distbn;
void updateDstbn(List<WtdPres> newdstbn){
distbn = newdstbn;
}
final dstbnsrc = new EventSource("../dstbns")
..onMessage.listen((event){
List wps = JSON.decode(event.data);
List <WtdPres> newdistbn = wps.map((wp) => new WtdPres.fromJson(wp));
updateDstbn(newdistbn);
});
}
The error I got in pub build was:
web/provingground.dart:55:5:
'updateDstbn' is only available in instance methods.
updateDstbn(newdistbn);
^^^^^^^^^^^
There are limitations on what you can do on initializers for final fields.
Can you try to put this code inside the constructor
var dstbnsrc;
ACDstbnController() {
dstbnsrc = new EventSource("../dstbns")
..onMessage.listen((event){
List wps = JSON.decode(event.data);
List <WtdPres> newdistbn = wps.map((wp) => new WtdPres.fromJson(wp));
updateDstbn(newdistbn);
});
}
I am trying to achieve a very simple goal in soapui
I have created a mock rest service in soapui that I can return static content from if the last resource matches a file name. problem is:
I use Spring RESTTemplate to make a REST call ala:
http://www.sample.com/user/group/{1}/status
where {1} is the only variable (it will be a number like 1111 or 2323)
In the OnRequest script section I should be able to write something simple that allows me to extract this resource from the full url and then craft a return of a static file of the same name ie:
ref = value.at.specified.location.{1}.in.url
return file(ref.xml)
any help translating these 2 pseudo code lines to actual working code would be helpful
this works:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
path = groovyUtils.getProjectPath() + "/docroot/" + mockRequest.getPath().tokenize('/')[4] + ".xml";
try
{
mockRunner.returnFile(mockRequest.httpResponse, new File(path));
mockRequest.httpResponse.status = 201
}
catch (Exception e)
{
mockRequest.httpResponse.status = 403
}
return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest);