I'm trying to access ajax (jquery-mobile and PhoneGap) to a web service (asmx), but something is wrong and what is not.
This is the js code:
$.ajax({
type : "POST",
url : webMethod,
data : param,
dataType : 'jsonp',
jsonp : 'callback',
jsonpCallback : 'jsonpCallback',
success : function(data) {
alert(data.nombre);
},
error : function(x,y,z) {
alert("-- " + x+'\n'+y+'\n'+z + " --");
}
});
function jsonpCallback(){
alert("OK");
}
and the web service (asmx)
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void WebServiceTest()
{
HttpContext.Current.Response.ContentType = "application/json";
string qs = HttpContext.Current.Request.QueryString["jsonpCallback"];
HttpContext.Current.Response.Write(qs + "( [{ \"name\": \"John\", \"message\": \"Ok\"}] )");
}
When I run the debug gives me an error -->
callback=jsonpCallback&_=1343139529496 500 (Internal Server Error)
I have already tried a thousand things (or at least that's the feeling I have ...)
I would greatly appreciate your suggestions.
P. S. Forgive my poor English
Related
I keep getting the HTTP 500 Internal Server Error in my android studio trying to call a loginQuery with apollo client for android, following this tutorial : link to apollo docs
Yet when I run the same query in graphiQL in my browser, it succeeds.
here's a picture of the error in studio :
here's my code:
String userNumber = numberInput.getText().toString();
String password = passwordInput.getText().toString();
Intent intent;
LogInQuery logInQuery = LogInQuery.builder().nationalID(userNumber).password(password).build();
apolloClient.query(logInQuery).enqueue(new ApolloCall.Callback<LogInQuery.Data>() {
#Override
public void onResponse(#NotNull Response<LogInQuery.Data> response) {
LogInQuery.Data data = response.getData();
List<Error> error = response.getErrors();
assert error != null;
String errorMessage = error.get(0).getMessage();
assert data != null;
Log.d(TAG, "onResponse: " + data.login() + "-" + data.login());
if(data.login() == null){
Log.e("Apollo", "an Error occurred : " + errorMessage);
runOnUiThread(() -> {
// Stuff that updates the UI
loading.setVisibility(View.GONE);
Toast.makeText(LogInActivity.this,
errorMessage, Toast.LENGTH_LONG).show();
});
} else {
runOnUiThread(() -> {
// Stuff that updates the UI
loading.setVisibility(View.GONE);
Toast.makeText(LogInActivity.this,
"New User Created!", Toast.LENGTH_LONG).show();
//Intent intent = new Intent(LogInActivity.this, LogInActivity.class);
//startActivity(intent);
});
}
}
#Override
public void onFailure(#NotNull ApolloException e) {
runOnUiThread(() -> {
Log.e("Apollo", "Error", e);
Toast.makeText(LogInActivity.this,
"An error occurred : " + e.getMessage(), Toast.LENGTH_LONG).show();
loading.setVisibility(View.GONE);
});
}
});
}
I can't find much on the internet to help me solve it. If it's duplicate, direct me to the correct answer.
Check your API in Postman. It's working fine or not! Please share API if possible.
As per requirement, I need to turn on device registration to Always. However, our SRP flow starts failing with the below issue.
{ code: 'UnknownError', message: 'Unknown error, the response body from fetch is: undefined' }
After doing some research, I found one similar post, but it seems like the only solution is to turn device registration off.
It's failing while running node get-token.js script to retrieve token for our CI/CD testing pipeline.
cognitoUser.authenticateUser(authCfg, {
onSuccess: function (result) {
console.log("Result : ", result);
const token = result.getAccessToken().getJwtToken();
resolve(token)
},
onFailure: function(err) {
console.error("Failure : ", err);
console.log(new Error().stack);
reject(new Error("An error occurred: " + err))
},
newPasswordRequired: function (userAttributes, requiredAttributes) {
cognitoUser.completeNewPasswordChallenge(p, userAttributes, this);
},
});
Seems like I missed the point mentioned in this post . Adding the below code works.
const WindowMock = require('window-mock');
global.window = {localStorage: WindowMock.localStorage};
global.navigator = () => null;
I am trying to use Facebooks post to page feature of the GraphRequest API but I am running intro trouble trying to post child attachments. It says it expects the child attachments field as an array (https://developers.facebook.com/docs/graph-api/reference/v2.5/page/feed)
but when I give it in the following format, react native spits out the following error:
JSON value '(
{
link = "google.com";
picture = "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png";
}
)' of type NSMutableArray cannot be converted to NSString
Code Below:
const postRequestParams = {
message: {
string: 'Hi!'
},
child_attachments: {
string: [{link: 'google.com', picture: 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'}]
}
}
const postRequestConfig = {
httpMethod: 'POST',
version: 'v2.10',
parameters: postRequestParams,
accessToken: pageAccessToken
}
new GraphRequestManager().addRequest(new GraphRequest('/' + fb_page_id + '/feed', postRequestConfig, (error, result) => {
if (error) {
console.log(error)
//alert('Error Sharing Post to Facebook: ' + error.toString());
} else {
console.log("post ot Fb page was successful")
}
})).start()
On calling my web service from my app.component.ts file I am getting the below error when I run the app in VS Emulator for Android. Can someone please provide a solution?
In the ngOnInit() life cycle hook of app.component.ts I am accessing the data from the web service class
app.component.ts(excerpt)
ngOnInit()
{
this.myDataService.openWebMwthod()
.subscribe((response)=>{
this.datas = response;
JSON.stringify(this.datas);
alert("here"+this.datas);
if(this.datas == null || this.datas == "")
{
this.nav.setRoot(this.accessDeniedPage, {showFooter : false});
}
else
{
this.nav.setRoot(this.homePage, {showFooter : false});
}
});
}
Below is my Web Service class excerpt where I am making a REST call:
my-mobile.dataservice(excerpt)
public openWebMwthod() : Observable<any>{
this.initializeApp();
let details = {
"EmpID" : this.sapId
};
let body = JSON.stringify(details);
let headers = new Headers(
{
'Content-Type': 'application/json',
}
);
let options = new RequestOptions({headers:headers});
return this.http.post(URL,body,options)
.map( (res) => res.json())
}
Just add this code to your config.xml
<preference name="loadUrlTimeoutValue" value="700000" />
Am trying to sign the XML using my private key, and using SOAP UI
it gives the proper success response.
to generate the request am using below code
var Authorization = 'Basic ' + new Buffer((sapConfig.sap.username + ':' + sapConfig.sap.password) || '').toString('base64');
soap.createClient(__dirname + '/wsdl/SI_CARWORKZ_Customer_Sen_Sync.wsdl', wsdlOptions, function (err, client) {
client.setSecurity(new soap.WSSecurityCert(privateKey, publicKey, password, 'utf8'));
//client.setSecurity(new soap.ClientSSLSecurity(privateKey, publicKey, ca));
client.SI_CARWORKZ_Customer_Sen_Sync(details, sslOptions, function(err, result, raw, soapHeader) {
console.log('%j', result);
if(_.has(result, "ResponseData") && !_.isEmpty(result.ResponseData.Item)){
var status = _.pluck(result.ResponseData.Item, "Status");
if(status.indexOf('E') != -1){
return callback({status: "error", data: result});
}else{
// insert the user in mongodb
sapLogs.insertCustomers(details.HEADER, function(result){
console.log("customer added");
return callback({status: "success", data: details});
})
}
}else{
return callback({status: "error", data: [], message: "something went wrong." })
}
}, {"Authorization": Authorization});
});
But when am sending the signed xml data using the script it shows me error
Error while valdiating the digital signature. The error was java.lang.NullPointerException while trying to invoke the method com.sap.security.core.ws.wss.tokens.securitytoken.BinarySecurityToken.getSecurityToken()
Is there any issue with my public key or private key?
I have exported them from jks file which is used in SOAP UI.