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.
Related
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?
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);
I have an issue with obtaining data from Windows Azure's runtime using the newest (at the time of writing) PHP SDK from Github. Here is a test I am running on one of our hosted services:
<?php
include 'WindowsAzure/WindowsAzure.php';
use \WindowsAzure\ServiceRuntime\RoleEnvironment;
use \WindowsAzure\ServiceRuntime\Internal\RoleEnvironmentNotAvailableException;
try {
echo RoleEnvironment::getDeploymentId();
}
catch (RoleEnvironmentNotAvailableException $Exception) {
die('Failed to find deployment id');
}
RoleEnvironmentNotAvailableException is always thrown. Looking at the source, it seems to try sending commands through a named pipe (\.\pipe\WindowsAzureRuntime). Do I need to specify something within my ServiceConfiguration.csdef/cscfg in order to have access to this named pipe?
Any advice would be most welcome!
Got confirmation from MS EMEA Developer Support that current SDK does not support this function. They suggested similar workaround to jonnu above - use the previous SDK's functionality for role environment / configuration settings.
The ServiceRuntime APIs run only on Cloud so if this code snippet runs on local machine it'll throw an exception as you've pointed out. Further, if you want to debug your ServiceRuntime code you've to deploy your service to WA then use remote desktop connection to access the cloud machine and debug your code.
When I try to use SoapClient:
try {
$client = new SoapClient('http://someurl/somefile.wsdl');
} catch (SoapFault $e) {
var_dump($e);
}
I have catch error with:
["faultstring"] => "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://someurl/somefile.wsdl' : failed to load external entity "http://someurl/somefile.wsdl"
["faultcode"] => "WSDL"
I can manually download http://someurl/somefile.wsdl and can file_get_contents for this file. I try to use it before on different computer and it worked. Possible problem with php or apache settings..
ArchLinux with last updates for php and apache. I tried to enable all php extensions.
Were you able to get wsdl using file_get_contents() in browser?
I had similar issue recently in Archlinux with same faultstring, no matter what wsdl file was used. The same code was working without any problem on other Archlinux machine and Windows XP box.
After some research, it came out that problem arose only when I tried to access the page in browser - script accessed from command line worked as expected. Then I changed the script to download the wsdl file directly, using aforementioned file_get_contents() - it gave me a warning "php_network_getaddresses: getaddrinfo failed: Name or service not known".
Few tutorials (on SO, or this one: http://albertech.net/2011/05/fix-php_network_getaddresses-getaddrinfo-failed-name-or-service-not-known/ ) later I haven't fought off the problem yet. But then I discovered what introduced the issues: I had been running NetworkManager since the installation of Arch (to better handle wireless), and few weeks later I've added mysqld and httpd as last to DAEMONS section in rc.conf - it seems this broke DNS resolution for apache.
Having two solutions (go back to starting servers manually or try other network manager) I've switched to wicd and haven't run into the issue again.
I have some code that connects to a newsletter service via SOAP. It works with no problem on our dev server, but on our live server it doesn't work at all. It's not returning any errors; just a blank white page. I've put some error_logs into the code and found exactly where it stops working - on the line creating the new SoapClient. Is there some kind of server config that needs to be set? Our code is identical between dev and prod, so the only thing I can figure is a server issue. (Note that the first chunk of code below was provided by the newsletter service, not written by me.)
# bronto API session/connection setup
ini_set("soap.wsdl_cache_enabled", "0");
date_default_timezone_set('America/Chicago');
$wsdl = "https://api.bronto.com/v4?wsdl";
$url = "https://api.bronto.com/v4";
/*error log statements up to this point return what is expected;
an error log after the following line (starting with $client = new SoapClient)
does not get triggered at all. */
$client = new SoapClient($wsdl, array('trace' => 1, 'encoding' => 'UTF-8'));
$client->__setLocation($url);
$token = "XXX";
$sessionId = $client->login(array("apiToken" => $token))->return;
$client->__setSoapHeaders(array(new SoapHeader("http://api.bronto.com/v4",
'sessionHeader',
array('sessionId' => $sessionId))));
I've also tried something like this to explicitly see any errors, but no luck - still nothing in the error log.
try {
$client = #new SoapClient($wsdl, array('trace' => 1, 'encoding' => 'UTF-8'));
}
catch (SoapFault $E) {
error_log($E->faultstring) ;
}
error_log("ok");
I would check the installed PHP packages on the dev server and compare to the Prod server. fr2.php.net/manual/en/soap.setup.php
This will more than likly be a config setup for php on the live server, but here are the common problems i have had with SOAP on php,
First thing is check the allowed memory for php on live comparable with dev (SOAP is big and bad for memory)
Is the php on the live server the same version as the dev server,
Is the live server authorized to access the SOAP server (if auth is used on an IP Level)
as one of the SOAP packages i have used did this to me i found out there was a version mismatch, last but not least could you tell us what SOAP Library if any other then php default your using so we can help as your code looks good :)
thinking about it have you install soap i don't think php natively supports it i think its a pear or pecl package and if your using XAMPP or easyPHP on dev these have all of both all ready included in php.