A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearBest method for debugging a called webservice in php? - page 1
User InfoPosts
Best method for debugging a called webservice in php?#1
I have an n-tier system where a frontend templating layer makes calls out to a backend application server. For instance, I need to retrieve some search results, and the frontend calls the backend to get the results.

Both the templating engine and the appserver are written in PHP. I currently use PHPed to initiate debug sessions to the templating engine, however, when the http request goes out to remote service my debugger just sits and waits for the IO to complete.

What I would like to do is emulate the HTTP call but really just stay inside my PHP process, do a giant push of the environment onto some kind of stack, then have my appserver environment load and process the call. After the call is done, I do an env pop, and get the results of the http call in a var (for instance, via an output buffer). I can run both services on the same server. Does anyone have any ideas or libraries that already do this?

posted date: 2009-04-13 20:42:00

Re: Best method for debugging a called webservice in php?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-13 20:42:01

Re: Best method for debugging a called webservice in php?#3
Can you not run a debugger and set a breakpoint in the appserver too? Two different debug sessions - one to trap the templating engine call and one to trap the call in the appserver.You should be able to trace the output from the appserver in the templating engine debugging session.If it is not possible to run two debug sessions then create some test inputs for the appserver by capturing outputs from the templating engine and use a single debugger with your test appserver inputs.

posted date: 2009-04-15 04:13:00

Re: Best method for debugging a called webservice in php?#4
Good idea... In PHPed at least, the debug engine passes a debug ID so the called process can "phone home" to the IDE. I will see if I can figure out a way to have that debugID passed along on the second call, and maybe I can get the debuggger to spark a new session.

posted date: 2009-04-15 10:17:00

Re: Best method for debugging a called webservice in php?#5
This is embarrassingly crude, and quite free of any study of how the debugger works, but have you tried adding debugBreak();at the entry points to your called routine? (Assuming both processes running on the same machine).I have used this technique to break back into a process called via AMFPHP. I have had a PHP file loading Flash file into browser, which then calls back to PHP using AMFPHP, all on the same server. When I hit the debugBreak() line, PhpED regains control.

posted date: 2009-04-21 02:07:00

Re: Best method for debugging a called webservice in php?#6
Why don(t you use an HTTP sniffer? Something like tcpflow. Alternatively, you could just log the complete XML to a file for each request & response. Unfortunately it(s not clear from your question what you(re trying to achieve so these are just guesses. You should probably state more clearly exactly what problem you(re trying to solve.You could possibly re-factor your code that calls out to the remove service and use dependency injection and mocks. That would allow you to isolate the development of the front-end with the back by suppling "mocked" but valid data.Hope that helps.

posted date: 2009-04-21 16:03:00

Re: Best method for debugging a called webservice in php?#7
Can I assume you(re talking about the lack of threads in PHP, so the service stops the flow of your program and halts the debugger? There(s ways around it, but they are hard, cumbersome and hackish.For example, if you use a framework like Zend for the HTTP traffic, you can hack the HTTP class to use primitive sockets for the service reading/writing instead of the built-in stuff, and create a small task switcher (loop :) to track what(s going on.You could of course use fopen ( (http://...( ) and fread in chunks in a loop as well, that could do the trick, but you need http: support in streams turned on.

posted date: 2009-04-23 05:27:00

Re: Best method for debugging a called webservice in php?#8
I don(t know much about PHP debugging, and I(m not sure I follow (push of the environment onto some kind of stack(, but I wonder if netcat + some shell scripting could be useful here for troubleshooting ?You can use netcat to:Spoof an HTTP RequestAct like a webserver (listen on a port - pick a port, any port!)http://www.plenz.com/netcat-tipsYou could use it to stub out a fake webservice on the one end:echo "<xml .. <node>hello php!</node>" | netcat -lp 80 ... etc... and you can certainly use it listening on a port to very clearly see what the incoming requests to the webservice look like. Could you use a shell script with netcat as middle man that acts like your webservice, immediately returns something generic to make your PHP happy, then passes the request on to your actual appserver and logs the results?Super simple.

posted date: 2009-04-24 08:56:00

Re: Best method for debugging a called webservice in php?#9
This is not open source, but check out Charles. It works as a proxy, and is the best debugging proxy I(ve seen to date. It works on linux, os/x and windows.Pretty much any HTTP library will allow you to specify a proxy.

posted date: 2009-04-25 08:09:00

Re: Best method for debugging a called webservice in php?#10
PhpED supports parallel debug sessions - meaning you can start debugging code that issues request to initial server and then inter-server requests too. All you need is to set breakpoints in corresponding projects and pass debugger request between the servers. Normally you can do this by re-transmitting value of DBGSESSID (the debugger request) variable with its value to the 2nd server. The variable can be found among $_COOKIES and/or $_GET (depending on how you start debugging -- from the IDE or usign Debugger Toolbar). To re-transmit the variable to the secondary server(s) you can add it to POST variables or as URL parameter or cookie. If you can(t do that f.e. if your server filters out all from get/post/cookies, try to embed DebugBreak() call.Make sure that all your servers can find the IDE by its IP address in the request and allowed to connect back to the IDE -- e.g. you have necessary rules in firewall and LinuxSE (buy default this SE layer is enabled in all modern Linuxes these days). It took me a day to figure out why my server can(t connect.In case if connection from the server to the IDE is not possible (if workstation with the IDE is in a different network, for example at your home), you can use ssh tunnels. In this case the IDE address is localhost, of course.

posted date: 2013-04-03 22:59:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.