I've had plenty of issues with PHP and apache caching things whenever it feels like it and I seems like it's always next to impossible to get rid of it.
I currently have the following problem: I'm writing a PHP stub to call a local web service in Java as an RPC. After making changes on the Java Soap side, my simple PHP unit test still thinks the old functions are still there.
I know Java is not caching because when I check the WSDL file in a browser, everything is fine, but PHP is not even responding to changes and thinks the old ones are still there!
I'm fed up with PHP! How do I make PHP stop doing this? How is anyone suppose to activity develop anything when it caches every other second?
EDIT:
The php is a very simple RPC.
$client = new SoapClient("http://localhost:9999/ws/login?wsdl");
$functions = $client->__getFunctions();
var_dump ($functions);
The functions simple do not reflect what's in the WSDL file so it's obviously not even bothering to check.
Per Owen's answer, you can disable WSDL caching with this which you should probably run in unit tests. I suppose it's enabled by default somewhere in an ini file or something.
ini_set("soap.wsdl_cache_enabled", 0);
Related
I am trying to write an API for a project at my university using RESTlet and Google App Engine in Java. At the moment, I am able to run a web server, but I am having some trouble accessing anything except from the root. Whenever I go to "/road" (which should be serving RoadResource), the web server just displays the RouteResource that is served for the root.
According to Eclipse, I get a HTTP OK 200 status code which seems meaningful although it is handling the wrong file.
The five files related to the project can be found here (except from the jars):
https://gist.github.com/majjoha/cd76272b5d6e6c368951
Since I am not able to post more than two links in a post, I've assembled the links in a gist instead.
Somehow, I think it is a minor configuration I've missed but if any of you can help me out, I would be very grateful.
What happens if you remove:
component.getDefaultHost().attach("/road", new RouterApplication());
from your RestletServer code?
I think that you just need to attach your Router application and that is what handles both the default route and your /road route. Also if you change
router.attachDefault(RouteResource.class);
to
router.attach("/", RouteResource.class);
it may be easier to track down how the routing error is occurring.
I've been tasked with creating a server which will receive requests for information from an iOS device (iPhone) and then return results based on this request. I've done some research, and it seems that JSON is the way to go for this task. The thing is that I have no idea where to start; how my server should be put together, how it will handle requests etc. Can anyone point me in the right direction and perhaps suggest some reading?
If you are comfortable with Java, I would recommend getting the Eclipse JavaEE version, and then:
Create a new "Dynamic Web Project".
File/New/Other/Web/Dynamic Web Project
Then, in your new project, create a "New Servlet".
File/New/Other/Web/Servlet
This should create a skeleton server, with a doGet and/or doPost method.
You can debug the servlet right away with Eclipse; it helps you get everything set up (comes with Jetty built in, these days)
You can be set up with your first webserver in 20 minutes.
Grab the JSON jar from json.org. Drop it in WebContent/WEB-INF/lib inside your project.
In the doPost of your new servlet, call request.getParameter(...) with the name of your post param that has the json in it.
Pass that to the JSON parser.
To pass JSON back, get the JSON string from a JSONObject, and use response.getWriter().append(...)
Ta-da!
Pretty brief answer, but then again, it's a pretty open question.
If you want to build it in Java and want to use what all the cool cats are using, Dropwizard is the way to go. It's geek factor has increased after its last photo session for Vogue (either that or the newest edition of Thoughtworks technology radar). No, really - it's good and extremely easy to deploy and monitor.
If you just want to get it done and over with, a short PHP script is the way to go.
WARINING: If you don't know PHP, it's fine: you can still use it. If you don't know Java, stay away from it. Learning Java on the go is a big mistake.
You can get started fast using Spring Roo. It can automatically create controllers for your domain objects that return JSON data for Restful requests.
I have a java program that runs on a couple different computers and I want to be able to be able to access them remotely. I don't need to do anything crazy, just some very basic input output (get and set type stuff). I could write a client type application and set each program to a server with RMI and do it that way but I will not always be on the same computer and do not want to have to carry the .java file around with me.
I'd prefer to write a simple php webpage that I can access from anywhere and have some very basic buttons that could send the commands to the different Applications and receive back some output.
Problems is that it would probably impossible to get my host to load anything other then php onto the server where I'd host my webpage.
Does anyone have any ideas? I've tried googling it and found a couple things out there that sort of sound like what I need but the more I look into them they seem to not be what I wanted after all.
If you really want to do this right I'd suggest looking at a Java web framework (I use Play! myself) to create a RESTful web service and then sending requests from your PHP code that will fetch JSON data.
A framework like Play will make it very easy to get a REST web service running. Just create some wrappers that invoke your existing java code and call renderJSON to output the result.
From the PHP code you'll issue the request using curl and then read the response using json_decode which will turn it into a handy php variable.
This also has the advantage that either end can be changed without the other noticing, as long as the json data format is kept the same.
Based on the way you described your setup you'll probably run into routing issues trying to reach your Java apps from your PHP host. I'd recommend you try something else: have your Java apps frequently check with your PHP app if there are any updates. You can simply use a Java URL connection and a timer:
http://download.oracle.com/javase/6/docs/api/java/util/Timer.html
http://download.oracle.com/javase/6/docs/api/java/net/URL.html
Wondering if anyone knows if there is a way to "return" something from a java web start application into the code on the website. For example say the user needed to select a location in the java application. This would then pass the location value back to the code on the webpage (which is php and javascript). I have figured out how to pass arguments into a program, but so far cannot figure out any way to get them out after much googling. Any help would be much appreciated, thanks.
In principle no, since the Webstart application can be running without any Website open at all.
But if your clients use the Java-plugin from 1.6.0_10 or later (and not Safari and some other browsers with special Java-handling), you can use a JNLP-enabled applet, which is able to do the same things as a Webstart application (i.e. loading files and such), and is always bound to a webpage. It then can use the Javascript-bridge, or simply a loadDocument with the right parameters to feed back information.
You can use URL or sockets to connect back to the "same-origin" host. You can also use BasicService to open a web page, possibly from a different server, in a browser (although this shouldn't be used to send information back, as it'll be a GET not a POST).
I have a Java program that I'm trying to interact with over the web.
I need to gather form data from the user on a Drupal site that I don't have any control over, send it to the Java program, and send the output back to the user. The Java program needs to load a lot of libraries every time it's run, so it needs to be up waiting for data from the user.
It'd be best for me to just have an HTML form for the input. What's the simplest way to deal with HTML form data using Java?
Also, I'm trying to call the Java program from a shell script. I want the program running in the background though so the libraries are loaded in advance. So ideally, I could use the server I set up for both applications.
Thanks for any help.
It sounds like you really just want to write a servlet (or use a higher level web framework, but a servlet would work fine). That makes it very easy to get web form data - you just ask for values by name, basically.
You could then "script" the application using curl, wget or something similar to make requests to the servlet.
Apologies if this doesn't answer your question - I'm finding it slightly tricky to understand exactly what you're trying to do, particularly as there are multiple layers of web UI involved, as far as I can see.
The easiest way to make POST requests with java is to use the Apache HttpClient or the more recent HttpComponents libraries.