Zend Soap Server with wsdl - 403 Forbidden - php

I'm working on a project with ZF in windows environment (using wamp) trying to develop a web service (wsdl definition) with the Soap library of Zend.
Everything works as expected at localhost, the URI http://localhost/mySite/webService/Server.php?wsdl returns a good definition of the service and it can be consumed. But the same using an IP like, let's say http://192.168.1.20/mySite/webService/Server.php?wsdl doesn't seem to be available. I get the error:
Forbidden
You don't have permission to access /mySite/webService/Server.php on this server.
I did the test using http://192.168.0.20/mySite/public/ and it works fine. I get the standard "Welcome to the Zend Framework!" because I haven't changed it yet (it even works using my public IP). In the same project I have some controllers/actions and they fail the same way.
I think the problem could be related with the httpd.conf file, but I don't really know how to handle it. Or maybe the .htaccess on this project?
Has somebody a clue?
Thanks.

Try without cache in your client:
$options['cache_wsdl'] = WSDL_CACHE_NONE:
$uri = http://192.168.1.20/mySite/webService/Server.php?wsdl;
$client = new Zend_Soap_Client($uri, $options);

Related

PHP / Laravel and Jenkins

I'm Integrating Laravel and Jenkins, and it seems to be working.
The only problem I have is that all my tests are used with base Url : http://localhost.
So All my tests fails because it says:
http://**localhost**/path/to/uri] failed. Received status code [500].
So, all the test fails because I guess I don't know
Where should I define what should be the http://localhost to be the baseUrl I want.
What should I put here, or where should I configure it... I could log ssh to my Jenkins machine and curl my url to see what's the response to see if it is responding well, but I'm quite unsure how should this work...
Any help will be appreciated!
Open TestCase.php which is inside test folder. There you should have protected $baseUrl which should be your application URL.

CakePHP : REST API 404 Error

I have build a REST server and trying to make my java application communicate to it.
But I keep getting a 404 error.
When I type in the url in my browser along with the function name like:
[url]/controller/functionname/1.json
it works fine, returning me the right data.
Without the function name:
[url]/controller/1.json
I get this error:
"action 1.json not defined in controller".
I've checked my .htaccess file and routes against a previous version I had build which was working just fine. I can't figure out what the problem might be. Any suggestions?
And oh, I should mention, the earlier version that I talked about was build on windows and this one on ubuntu.

SoapClient fails to load WSDL where SoapUI has no issue

At my office I can connect directly to the relevant soap servers and my code works as it should.
However - because of security - it is not allowed that VPN connections (from home) access the SOAP servers. So I have to resort to using an SSH tunnel over a jump-station.
Because the WSDL files contain absolute urls I can't use the "location" to change this, it won't load the WSDL. Therefor I've resolved to adding entries to the hosts files mapping that server name to 127.0.0.1 and and SSH tunnel to our jumpstation forwarding the correct ports.
This allows me to use the original WSDL without modification. I just have to comment out the hosts entries when at the office.
Via SoapUI everything works. I can load the WSDL, it fully parses it (it has a lot of includes - big corporate soap service) and I can launch SOAP requests that get answered correctly.
However, if I do the same via the php SoapClient (running against an apache on localhost) it throws an exception:
SOAP-ERROR: Parsing Schema: can't import schema from 'http://wsdl.service.addres:port/wsdlUri?SCHEMA%2Fsoa.osb.model%2Fsrc%...'
(I've replaced the server and the rest of the request because its not relevant.)
If I take that entire URL and paste it into my browser it results in an WSDL-XML.
The PHP code to load create the SoapClient is as simple as this:
$options =
[
'trace' => 1,
'exception' => 1,
];
$wsdl = '/path/to/local/wsdlfile.xml';
$client = new \SoapClient($wsdl, $options);
Anyone have a clue where to look? I can't think of anything to try anymore.
I know for sure that my PHP is setup correctly (as the code has been working for months at the office and nothing was changed here). Is PHP doing DNS resolving differently and somehow getting another (or no) IP for that corporate server perhaps?

Why can't I use SoapClient::multiCall on my server?

I am writing some php code for interfacing with a magento server and am trying to group my soap calls.
The magento wiki suggests the use of SoapClient::multiCall and I am able to get that to work fine on my home machine.
But If I try the exact same code on my server it tells me:
SoapFault exception: [Client] Function ("multiCall") is not a valid method for this service
The php manual for SoapClient doesn't even list multiCall as a method.
My home machine is running php version: PHP 5.3.3While the server is running version: PHP 5.2.14
I'm at a loss for what's happening here any help would be appreciated.
Here is the code I'm running:
$client = new SoapClient($wsdl_location);
$session = $client->login($user, $pass);
$client->multiCall($session, array(
array(catalog_category.currentStore),
array(catalog_category.currentStore)
)
);
Well I feel like a fool, it was a problem with the WSDL.
I was using different WSDLs on my home machine and server.
When I changed the URL from:
http://yourmagentohost/api/v2_soap?wsdl=1
to:
http://yourmagentohost/magento/api/?wsdl
You'll notice that I didn't have the /magento/ in my original URL.

Zend_OpenId_Consumer login function hangs - even in the sample code

I've been trying to get a simple OpenId log-in working using first php-openId (Jain) and then the ZendFramework, and in both cases I run up against a similar problem. I'm using the example Zend code from step 38.2.2 of http://framework.zend.com/manual/en/zend.openid.consumer.html.
I see the log-in page fine, but when I enter my openId, this code executes:
if (isset($_POST['openid_action']) &&
$_POST['openid_action'] == "login" &&
!empty($_POST['openid_identifier'])) {
echo "New consumer";
$consumer = new Zend_OpenId_Consumer();
echo "Gotim";
if (!$consumer->login($_POST['openid_identifier'])) {
$status = "OpenID login failed.";
echo "Failure";
}
echo "Continuing";
The code seemingly hangs on the function call to $consumer->login. I see the output from my first two echos, but I never see either Failure or Continuing (and without the echos I just get a 500 Server Internal Error when I try to log-in). If I enter an invalid openId then I get the correct "OpenID login failed." error message.
I apologize if I'm being a moron here. I'm a former programmer who got promoted to management, and I'm trying to get back into it - but I'm using a bunch of technologies that are new to me (PHP, OpenID, Zend Framework), and this just isn't making any sense right now.
Does anyone have any ideas where to look? I can't believe that the Framework itself is bugged (especially not when I had a similar problem with the Jain openId stuff also). I'm using fatcow.com for web hosting - not sure if that's relevant.
Your code seems to be failing when trying to make the external HTTP connection to the OpenID provider. This could be caused by a number of things, but here's a couple suggestions:
Perhaps you're behind a proxy?
If not that, maybe your current host does not allow contacting remote servers using sockets (the url_fopen ini directive). The default adapter for Zend_Http_Client is its socket adapter.
So, I would recommend trying is to pass a Zend_Http_Client instance using a different adapter to your Zend_OpenId_Consumer class using the setHttpClient method.
There are a couple different client adapters available:
Zend_Http_Client_Adapter_Socket (default)
Zend_Http_Client_Adapter_Proxy
Zend_Http_Client_Adapter_Test
Zend_Http_Client_Adapter_Curl
Try something like this:
$client = new Zend_Http_Client(null, array(
'adapter' => 'Zend_Http_Client_Adapter_Proxy',
'proxy_host' => 'example.com',
'proxy_port' => 8000,
'proxy_user' => 'user',
'proxy_pass' => 'pass'
));
$consumer = new Zend_OpenId_Consumer();
$consumer->setHttpClient($client);
Your ISP should have documentation about their proxy, if this is in fact the issue.
If proxying is not your problem, try the curl adapter and see if you have any more luck.
I still don't really understand what's wrong, but I tried running the same code on a different web host (x10hosting.com) and my sample code worked immediately. Therefore I have to conclude that this is some kind of limitation of the Fatcow webhosting service, which is rather a shame. I guess I'll be changing hosts.
If you are getting a 500 error, there is definitely a more detailed message in the web server logs. If your server is running apache, then it is most likely under /usr/local/apache/logs/error_log or /etc/httpd/logs/error_log or something similar. I am assuming you are on a shared hosting plan, so you won't have access to these. You should contact your webhosting company, as they will be able to look through the logs for you.

Categories