I'm having a problem with the XML-RPC communication.
I have a XML-RPC Client made in Java with Apache XmlRpc and a XML-RPC Server made in PHP with PEAR's XML_RPC. The problem is that i get a "HTTP server returned unexpected status: Not Found" error. I tested the server with a PEAR XML-RPC Client and it works. I don't know what is the problem because i can't print the response of the server (i don't know how), but it seems that the authentication works, because if i don't input the correct username and passoword i get an authentication error.
Please help!
Thanks in advance.
Cristian
Start debugging, here some information from the PEAR XML_RPC documention:
setDebug()
$client->setDebug ( $debugOn )
$debugOn is either 0 or 1 depending on
whether you require the client to
print debugging information to the
browser. The default is not to output
this information.
The debugging information includes the
raw data returned from the XML-RPC
server it was querying, and the PHP
value the client attempts to create to
represent the value returned by the
server. This option can be very useful
when debugging servers as it allows
you to see exactly what the server
returns.
Source: http://pear.php.net/manual/en/package.webservices.xml-rpc.api.php
Make sure you are taking into account the package name with writing the interface stub in java, because by default it will tack that onto the from of the method it is trying to reference.
Related
What differentiate these 2 requests that cause them to have different results/responses from the server although they should be the same ?
Request initiated by Chrome after a simple
click/navigation(successful, response code is 302)
I simply copied
that request as a curl and imported it to Postman and then postman
hanged
I did the same with Java - HttpUrlConnection(mimicking all the request headers and cookies like Chrome sent), but it hanged and waited forever. Is this simply because of the server logic that doesn't accept non-browser client ?
Here are the steps that I tried:
1. Visited this link: https://www.tokopedia.com/p/handphone-tablet/handphone
2. I opened the inspector and opened the Network - All tab
3. I clicked one of the products
4. I clicked the top request from the Network - All tab
5. I copied it as cURL bash
6. I imported it to Postman
7. I ran that request
8. Postman hanged
Actually the problem might even go deeper than what the other answers say.
So neither the User-Agent request header nor telnet might solve that problem (unless you initialize the TLS handshake also with telnet MANUALLY, but that is near impossible to complete).
TLS fingerprinting
If the connection is an SSL/TLS connection, the server could detect which algorithm is used to generate keys, and most applications have their specific signature / cipher.
So only by the TLS handshake alone you can tell Chrome from Postman or FireFox or Java. Java usually - unless a JVM implementation REALLY wants to go off-road - has the same signature across all platforms, using the same cipher/algorithm across all implementations.
I am sorry I cannot properly recall the name of this technique. The first project I know that published this is called something like "A3" or "S3". Salesforce published an article about JA3 analysis. They describe the technique and show a list of signatures and applications so you can guesstimate what app you're talking to, without the need to even decrypt the data: https://engineering.salesforce.com/tls-fingerprinting-with-ja3-and-ja3s-247362855967
My Solution
I had that same problem too, wanted to scan the NVidia or AMD servers for graphics card availability. Did not work from Java, so after a lot of research, finding the project mentioned above, I simply used Selenium to control FireFox and that got the proper server responses and I achieved my goal this way.
The only way to be sure that the exact same data is sent is to manually send it yourself through something like telnet. I had a similar problem once- it turned out that the browser was sending the data in one big chunk, while my code was sending it line-by-line. No site should have this problem, but it's possible that it exists.
The server might be checking for User-Agent request header and will block traffic that does not originate from a browser. Try setting the header in curl or your Java Code to a value corresponding to (any) browser. I've encountered such behavior on some e-shops and commercial websites.
I have a requirement where I call a SOAP based web service from Java using Axis2 from eclipse. The web service code is in C#, with a BasicHttpBinding.
But when I call the method from the client stub I get this error.
org.apache.axis2.AxisFault: Object reference not set to an instance of an object.
Could anyone help me figure out this one? Is this on the service side or on the client side? Previously I got 'Internal Server error' and then they had to add something so that I can see this error in the logs.
The message is from the C# web service side ("Object reference not set to an instance of an object" is basically a Java equivalent of NullPointerException) but it might be because of something you send from your Java client or maybe you don't send.
The error usually means that you didn't send a required parameter and that the web service didn't do a proper job of validating it's input and missing parameter got to a point when caused the NullReferenceException.
But there is only one way to be sure, and that is to troubleshoot the call.
I suggest you use something like SoapUI to create a message and send that to the service. Once you get a succesfull call in SoapUI, make a call with the same parameters from your Java client and see what happens. When you do that, using a proxy for logging is very useful to see if the sent message is actually the expected one.
I have PHP script on the server side which executes the SQL query and produces a JSON string from it. But how do I get that code to execute to then retrieve and decode the JSON on the Android app?
I am quite new to android so as much help would be very appreciated.
I can't write you the whole tutorial but i can give you a to-do list which you can check your progress.
Your application to generate JSON script in txt, or real time response.
Setup your backend server(you have sql server already and also PHP, so i guess you have set it up already, probably WAMP or similar), which is the endpoint/url path to generate the response required, in this case your JSON response.
Check the API is working or not by using "advanced rest client" or simple type your endpoint in browser, if you can get the correct response from it, the API is working as expected.
Created your android app, with simple HTTP request/response, send a HTTP request to the url/path you setup, see if you can get the JSON response or not.
Please comment here if you need further details, this is relatively easy and should be able to finished in 1 day for beginner.
I have 2 calls to the graph api
https://graph.facebook.com/oauth/access_token
https://graph.facebook.com/me
the first one returns with success but the second one always returns an error (400 bad request).
Funny thing is that when i copy the created url in the browser it returns the data as expected, only if ran through the java code as an http client call it throws an error. The url is fine and the access_token is also correct have verified on facebook debug.
Can any one please tell me what am i doing wrong.
Here is the sample url
https://graph.facebook.com/v2.4/me?access_token=sample_token&token_type=bearer&fields=id,name,email
You don't have the specify the token_type if you request Graph API objects. Try the following:
https://graph.facebook.com/v2.4/me?access_token=sample_token&fields=id,name,email
The problem was that with v2.4 there is an additional field required called appsecret_proof. Supplying that with the sha256 of the client secret and the access token solved the problem. And that too only for a server call.. works just fine without it from a client call. Thats why the browser call was working fine but not the web server call.
I am experienced with Java and have some experience with PHP (the server scripting language I will be using unless anybody tells me I shouldn't for some reason. I want to just send a string via POST to the server. Because there is not actually a webpage being created, I can't just echo the string if it is received. How should I test if the string was received by the server?
Edit:
After further research, it seems like echo doesn't just print to a browser, it sends a string through the http connection to whatever is connected to the php page. I should then be able to echo a response and receive it through an input string on the Java end. Is this correct?
You could use echo, as you mentioned, but the more common and reusable method of debugging PHP as you progress is the use of error_log(). You can view its output on the PHP server in the php.log file, commonly found at /tmp/php.log.
You can watch this file in real-time via the Unix command tail -f /tmp/php.log.
Further, you can output various forms of data by calling it with print_r() like error_log(print_r($data, TRUE));.
I believe you should be properly sending back Responde codes in your php scripts.
Please check: How to send a status code in PHP and Android: How get the status-code of an HttpClient request.