I'm trying to send some values to a web server and it is going to respond with true or false using http adapter in ibm mobilefirst. When i invoke the procedure from the environment, i got this error:
{
"errors": [
"Runtime: Http request failed: java.net.UnknownHostException: mfpreader.comze.com\/"
],
"info": [
],
"isSuccessful": false,
"warnings": [
]
}
Here is the link i'm using:
http://mfpreader.comze.com/login.php?username=kevin&password=pass
The server is working.
LoginAdapter.xml
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>https</protocol>
<domain>mfpreader.comze.com/</domain>
<port>443</port>
<procedure name="getVerify"/>
LoginAdapter-impl.js
function getVerify(pName) {
var input = {
method : 'get',
returnedContentType : 'json',
path : '/login.php',
parameters : {
'username' : pName,
'password' : 'pass' // hard-coded
}
};
return WL.Server.invokeHttp(input);
}
Can i have some help please. Thanks.
I think your issue is that you have a surplus / in your domain name:
<domain>mfpreader.comze.com/</domain>
This is a domain name, not a URL. You need to specify only the hostname of the server you are trying to reach:
<domain>mfpreader.comze.com</domain>
connect website using http port 80 .on the other hand return returnedContentType : 'plain' .
LoginAdapter.xml
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>mfpreader.comze.com</domain>
<port>80</port>
<procedure name="getVerify"/>
LoginAdapter-impl.js
function getVerify(pName) {
var input = {
method : 'get',
returnedContentType : 'plain',
path : '/login.php',
parameters : {
'username' : pName,
'password' : 'pass' // hard-coded
}
};
return WL.Server.invokeHttp(input);
}
invocation result:
{
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Connection": "close",
"Content-Length": "748",
"Content-Type": "text\/html",
"Date": "Fri, 19 Feb 2016 11:56:31 GMT",
"Server": "Apache",
"X-Powered-By": "PHP\/5.2.17"
},
"responseTime": 563,
"statusCode": 200,
"statusReason": "OK",
"text": "<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><font face='Arial' size='1' color='#000000'><b>PHP Error Message<\/b><\/font><\/td><\/tr><\/table><br \/>\n<b>Warning<\/b>: json_encode() expects exactly 1 parameter, 2 given in <b>\/home\/a1974455\/public_html\/login.php<\/b> on line <b>72<\/b><br \/>\n<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><div align='center'><a href='http:\/\/www.000webhost.com\/'><font face='Arial' size='1' color='#000000'>Free Web Hosting<\/font><\/a><\/div><\/td><\/tr><\/table> \n<!-- Hosting24 Analytics Code -->\n<script type=\"text\/javascript\" src=\"http:\/\/stats.hosting24.com\/count.php\"><\/script>\n<!-- End Of Analytics Code -->",
"totalTime": 578,
"warnings": [
]
}
The website does not work.
When you pointed to it, you're using http, but in the XML you're using https. And when trying to access the website with the https protocol, it is not loading.
Related
I'm struggling to go live. It's weird how something works in sandbox mode but then either there is no documented way to switch to production or it just does not work.
So here is what I got:
<template lang="pug">
.paypal
Spinner(:size="8" :thickness="3")
PaypalButtons.buttons(
:env="env"
:style="style"
:createOrder="order"
:onInit="init"
:onClick="validate"
:onApprove="approve"
:onError="error"
)
</template>
<script>
export default {
name: 'PayPal',
props: {
env: {
type: String,
default: 'sandbox',
validator: value => ['sandbox', 'production'].includes(value)
},
},
// ...
}
</script>
I've tried to set the env prop to production and removing it completely. I can not find any documentation on how to set the environment. I must miss something fundamental.
The error:
As I mentioned the sandbox mode works fine, but as soon as I go live (server side using PayPals production URL and client side with the corresponding env prop), I'm getting the following errors
Request
URL: https://www.sandbox.paypal.com/graphql?UpdateClientConfig.
BODY:
{
"query": "\n mutation UpdateClientConfig(\n $orderID : String!,\n $fundingSource : ButtonFundingSourceType!,\n $integrationArtifact : IntegrationArtifactType!,\n $userExperienceFlow : UserExperienceFlowType!,\n $productFlow : ProductFlowType!,\n $buttonSessionID : String\n ) {\n updateClientConfig(\n token: $orderID,\n fundingSource: $fundingSource,\n integrationArtifact: $integrationArtifact,\n userExperienceFlow: $userExperienceFlow,\n productFlow: $productFlow,\n buttonSessionID: $buttonSessionID\n )\n }\n ",
"variables": {
"orderID": "17884710UT885974F",
"fundingSource": "paypal",
"integrationArtifact": "PAYPAL_JS_SDK",
"userExperienceFlow": "INCONTEXT",
"productFlow": "SMART_PAYMENT_BUTTONS"
}
}
Response:
{
"data": {
"updateClientConfig": null
},
"errors": [
{
"_name": "RESOURCE_NOT_FOUND",
"checkpoints": [
"patchClientConfig"
],
"contingency": true,
"data": {
"message": "The specified resource does not exist."
},
"message": "RESOURCE_NOT_FOUND",
"meta": {},
"path": [
"updateClientConfig"
],
"statusCode": 200
}
],
"extensions": {
"correlationId": "464b1d56d4581",
"tracing": {
"duration": 98157194,
"endTime": "2021-09-06T16:29:45.133Z",
"execution": {
"resolvers": [
{
"duration": 96271082,
"fieldName": "updateClientConfig",
"parentType": "Mutation",
"path": [
"updateClientConfig"
],
"returnType": "Boolean",
"startOffset": 1222180
}
]
},
"startTime": "2021-09-06T16:29:45.035Z",
"version": 1
}
}
}
There is another request to https://www.sandbox.paypal.com/graphql?GetCheckoutDetails with a similar response.
As far as I can tell the request URL should not be www.sandbox.paypal...
I have also commented on an existing issue on GitHub, but I believe it will take too long to get an answer that way.
You are using a sandbox client ID.
Change to a live client ID, from an app in the "Live" tab of your Applications in developer.paypal.com
I am currently using Krakend (https://krakend.io) API Gateway to proxy request to my backend service. One of my backend service API response is a redirect response with http 303. The redirect response looks like this below :
HTTP/1.1 303 See Other
content-length: 48
content-type: text/plain; charset=utf-8
date: Thu, 16 Jul 2020 10:25:41 GMT
location: https://www.detik.com/
vary: Accept
x-powered-by: Express
x-envoy-upstream-service-time: 17
server: istio-envoy
The problem is that, instead of returning the http 303 response to client (with location response header) as-is, Krakend is actually following the http redirect and return the response of the redirect Url, which is the html response of https://www.detik.com/.
My current krakend configuration looks like this below :
{
"version": 2,
"extra_config": {
"github_com/devopsfaith/krakend-cors": {
"allow_origins": [],
"expose_headers": [
"Content-Length",
"Content-Type",
"Location"
],
"allow_headers": [
"Content-Type",
"Origin",
"X-Requested-With",
"Accept",
"Authorization",
"secret",
"Host"
],
"max_age": "12h",
"allow_methods": [
"GET",
"POST",
"PUT"
]
},
"github_com/devopsfaith/krakend-gologging": {
"level": "ERROR",
"prefix": "[GATEWAY]",
"syslog": false,
"stdout": true,
"format": "default"
},
"github_com/devopsfaith/krakend-logstash": {
"enabled": false
}
},
"timeout": "10000ms",
"cache_ttl": "300s",
"output_encoding": "json",
"name": "api-gateway",
"port": 8080,
"endpoints": [
{
"endpoint": "/ramatestredirect",
"method": "GET",
"extra_config": {},
"output_encoding": "no-op",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/",
"encoding": "no-op",
"sd": "static",
"extra_config": {},
"method": "GET",
"host": [
"http://ramatestredirect.default.svc.cluster.local"
],
"disable_host_sanitize": false
}
]
}
]
}
So how can I make krakend to return original http 303 response unaltered from my backend service to the client ?
Thank You
I assume that you're calling this endpoint /ramatestredirect
To get backend http status code (as you said it return 303 http status code), you can use this way:
{
"endpoint": "/ramatestredirect",
"method": "GET",
"extra_config": {},
"output_encoding": "no-op",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/",
"encoding": "no-op",
"sd": "static",
"extra_config": {
"github.com/devopsfaith/krakend/http": {
"return_error_details": "authentication"
}
},
"method": "GET",
"host": [
"http://ramatestredirect.default.svc.cluster.local"
],
"disable_host_sanitize": false
}
]
}
So, basically with this plugin you can get the original backend http status code
"github.com/devopsfaith/krakend/http": {
"return_error_details": "authentication"
}
If you use Lura Framework (formerly known as Kraken framework), then you may have to disable redirects for your http client.
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
While testing a HTTP adapter procedure code generated by "Create Data object from service" using Worklight Application Framework editor,it generates the following error:
Unable to handle request without a valid action parameter. Please
supply a valid soap action.
This is the web service URL: http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL
Invocation result of procedure:
{
"Envelope": {
"Body": {
"Fault": {
"Code": {
"Value": "soap:Sender"
},
"Detail": "",
"Reason": {
"Text": {
"CDATA": "Unable to handle request without a valid action parameter. Please supply a valid soap action.",
"lang": "en"
}
}
}
},
"soap": "http:\/\/www.w3.org\/2003\/05\/soap-envelope",
"xsd": "http:\/\/www.w3.org\/2001\/XMLSchema",
"xsi": "http:\/\/www.w3.org\/2001\/XMLSchema-instance"
},
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Cache-Control": "private",
"Content-Length": "500",
"Content-Type": "application\/soap+xml; charset=utf-8",
"Date": "Mon, 28 Apr 2014 07:56:34 GMT",
"Server": "Microsoft-IIS\/7.5",
"X-AspNet-Version": "2.0.50727",
"X-Powered-By": "ASP.NET"
},
"responseTime": 1476,
"statusCode": 500,
"statusReason": "Internal Server Error",
"totalTime": 1477,
"warnings": [
]
}
Support for SOAP actions in the HTTP header is being considered for a future release of Worklight.
If you wish to invoke the generated adapter in Worklight Studio v6.1 you will have to modify the generated SOAP adapter and manually add the action header.
For instance, for invoking a GetWeatherInformation operation you can open the generated adapter JS file and add the following lines:
headers = headers || {};
headers.SOAPAction = 'http://ws.cdyne.com/WeatherWS/GetWeatherInformation';
to the Weather_GetWeatherInformation function just before the call to invokeWebService at the end of this function.
I have deployed the adapter on Worklight server and there is some requirement where I am calling worklight adapter from outside as a rest serverice , it is working fine and returning data as required but instead of giving json output it is giving HTML
<!DOCTYPE html><html><head><meta charset="UTF-8" /><title>Invoke Procedure Result</title><script src="/secure/console/js/jquery-1.6.min.js"></script><style> textarea { width: 100%; } .textwrapper { margin: 5px 0; padding: 3px; }</style></head><body onload="attachEvent();"><div><span id="invRes">Invocation Result of procedure: 'Authentication' from the Worklight Server</span>: </div><div id="target"><textarea rows="20">{
"RESPONSE": {
"USER_ID": "292265"
},
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Content-Length": "1195",
"Content-Type": "text\/xml;charset=ISO-8859-1",
"Date": "Thu, 21 Nov 2013 10:10:13 GMT",
"Server": "Oracle GlassFish Server 3.1.2.2",
"X-Powered-By": "Servlet\/3.0 JSP\/2.2 (Oracle GlassFish Server 3.1.2.2 Java\/Oracle Corporation\/1.7)"
},
"responseTime": 4234,
"statusCode": 200,
"statusReason": "OK",
"totalTime": 4235,
"warnings": [
]
}</textarea></div><script>function attachEvent() {$('#target').ajaxError(function(e, xhr, ajaxOptions, thrownError){$(this).text("Error: Please ensure that the XML input and XSL transformation are valid and try again.");});}function run_xslt() {var xml = $('#originalXML').val();var xsl = $('#originalXSL').val();$.post('/secure/dev/xslt',{'xml':xml,'xsl':xsl},function(data, textStatus, XMLHttpRequest){$('#target').empty();json = $("<textarea></textarea>");json.attr("rows",25);json.text(data);$('#target').append(json);$('#invRes').text('Result of Local XSL Transformation');},'text');}</script></body></html>
in code I am again parsing it from HTML and storing json into string. Then only i can use it. This is the url given below for calling adapter externally as per worklight docs.
http://WorklightServer.com/secure/dev/invoke?adapter=Reports&procedure=Authentication¶meters=%5B%5D
remove /dev/ component from the URL, it is for development ease purposes only. without it you'll get your JSON.
I had the same issue and after reading Anton's answers I set the "dataType" of the Ajax call to "text" and then edit the response to remove the /*-secure- and */ and then parsed the string to get the JSON "JSON.parse(theString)"
$.ajax({
type: 'POST',
url: ajaxURL,
async: true,
cache: true,
timeout: 5,
dataType: "text",
success: function(data){
data = data.replace("/*-secure-","");
data = data.replace("*/","");
var dataJSON = JSON.parse(data);
//Do success
},
error: function(data, statusCode){
//Do error
}
});
I am retrieving information for a List via JSONP and am getting the following error in console browser: "unexpected token : "
My store:
Ext.define ('Projeto.store.Mural', {
extend 'Ext.data.Store'
requires: [
'Projeto.model.Mural'
]
config: {
autoLoad: true,
model: 'Projeto.model.Mural'
storeId 'MuralStore'
Proxy {
type: 'jsonp'
url: 'http://URL/mural'
reader: {
type: 'json',
rootProperty: 'rows'
}
}
}
});
My List:
Ext.define ('Projeto.view.MuralList', {
extend 'Ext.dataview.List'
alias: 'widget.murallist'
config: {
loadingText: 'Loading ...',
store: 'MuralStore'
itemTpl: [
'<div> Message: {message} </ div>
]
}
});
JSON returns my URL:
{
"rows": [
{
"lookup": "yyyy"
"dateTime", "10/10/1970"
"id": "1",
"message": "yyyy"
}
{
"lookup": "dsdfasfsadf"
"dateTime", "15/05/2012"
"id": "2",
"message": "dsdfasfsadf"
}
]
}
Does anyone know why the error, because JSON is in a valid format.
Thank you.
You're missing a comma in the middle :
{
"rows": [
{
"lookup": "yyyy"
"dateTime", "10/10/1970"
"id": "1",
"message": "yyyy"
},
{
"lookup": "dsdfasfsadf"
"dateTime", "15/05/2012"
"id": "2",
"message": "dsdfasfsadf"
}
]
}
My guess is that the service you're accessing returns JSON but not JSONP. Search the jsonp tag for "unexpected token". You'll find e.g. Why is this JSONP feed throwing "Unexpected Token" error?
Firstly, You'r missing ':' at many places and also ',' at the end of statements. It always good practise to use : before the property value and , at the end of statement.
Like this,
...
...
requires: [
'Projeto.model.Mural'
],
config: {
autoLoad: true,
model: 'Projeto.model.Mural',
storeId: 'MuralStore',
proxy : {
type:'jsonp',
},
....
....
Secondly, this error is occuring because your response is not a VALID jsonp response.
When I checked on jsonplint.com, it showed me this error
Invalid JSONP
No callback function defined
Improper or no closing
So, either you need to make sure that you have a valid callback function defined.
Otherwise, you could do one thing. Change the type:'jsonp' to type:'ajax' and that should resolve your problem without having to change anything else.
Since you are requesting it as jsonp, not just json, it expects your json to be enclosed in a callback function. Something like:
callback({
"rows": [
{
"lookup": "yyyy"
"dateTime", "10/10/1970"
"id": "1",
"message": "yyyy"
}
{
"lookup": "dsdfasfsadf"
"dateTime", "15/05/2012"
"id": "2",
"message": "dsdfasfsadf"
}
]
})