Last active
December 30, 2015 18:59
-
-
Save matejuh/7871449 to your computer and use it in GitHub Desktop.
Worklight showcase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMyAddress() { | |
var input = { | |
method : 'get', | |
returnedContentType : 'json', | |
path : "json" | |
}; | |
return WL.Server.invokeHttp(input); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<wl:adapter name="IPAdapter" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:wl="http://www.worklight.com/integration" | |
xmlns:http="http://www.worklight.com/integration/http"> | |
<displayName>IPAdapter</displayName> | |
<description>IPAdapter</description> | |
<connectivity> | |
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType"> | |
<protocol>http</protocol> | |
<domain>freegeoip.net</domain> | |
<port>80</port> | |
</connectionPolicy> | |
<loadConstraints maxConcurrentConnectionsPerNode="2" /> | |
</connectivity> | |
<procedure name="getMyAddress"/> | |
</wl:adapter> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDataFromAdapter(){ | |
WL.Logger.info("get data from adapter"); | |
var invocationData = { | |
adapter : "IPAdapter", | |
procedure : "getMyAddress", | |
parameters : [] | |
}; | |
WL.Client.invokeProcedure(invocationData, { | |
onSuccess : function(response){WL.Logger.info("OK: " + JSON.stringify(response.invocationResult)); alert(response.invocationResult.country_name + " " + response.invocationResult.city);}, | |
onFailure : function(response){WL.Logger.info("fail: " + JSON.stringify(response.invocationResult));} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment