Magento 1.9.1.0 : Unable to load WSDL using soap cleint - php

I have tried all the answers given in the following threads.
[1] Magento SOAP API - PHP Exception thrown for login method call: "looks like we got no XML document"
[2] Magento SOAP API - PHP Exception error “looks like we got no XML document”
I am able to load the WSDL in the browser and the WSDL URL is in this format
http://www.foo.com/api/v2_soap/?wsdl
This is the error am getting in the console:
looks like we got no XML document .

This error is usually related to Magento setting up a SoapServer, and not to your SoapClient call, which in turn means that it's usually a problem of your server not being able to fetch the WSDL. Connect toyour server via ssh and issue the following command (with your URL)
$ curl -i 'http://www.foo.com/api/v2_soap/?wsdl'
This will output the HTTP headers, and the response. My guess is the response isn't valid XML (includes debugging, or whitespace), curl couldn't connect to the server (because your host's networking is wrong) or your WSDL points to other WSDLs that can't be connected to.
Solve that problem, and you'll be good to go.

Related

Any way to force PHP SOAP to call HTTPS instead of HTTP?

I have a VERY simple PHP code:
<?php
$soap = new SoapClient('https://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl', array());
var_dump($soap);
When I copy that URL into my browser it loads just fine, with no redirects or anything:
$soap = new SoapClient('https://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl
But when I execute that PHP script I get the following error after a PHP timeout:
Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl=wsdl0' : failed to load external entity "http://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl=wsdl0"
Notice the response URL is http://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl=wsdl0 which is very similar but not quite accurate. If I search the working WSDL for that given URL I find it at the top:
That said, every URI points to HTTP instead of HTTPS, but if we simply change this in our browser the page loads just fine.
So the question becomes: when we create a PHP SoapClient, can we force all URIs to follow HTTPS regardless of the protocol specified in the WSDL?
The WSDL can stand by itself and contain everything inside, or it can use imports to bring in content from other locations (it usually happens with XSD schemas).
If it imports things, those imports need to be resolved by the client. If they can't be resolved, either because the location is wrong, or the protocol is wrong, or whatever, then the client bails out, because it needs a complete WSDL to understand the service's contract and how to call it, not just the parts it could load.
So you have two options:
Contact the provider of the service and ask them to fix it so all imports can be resolved.
If you can download the WSDL and all the resources it tries to import, by opening in browser and changing the protocol to https, you can save them all locally on disk in the same folder. Assuming you end up with a file named VehicleService.wsdl for the WSDL itself, and VehicleService.xml for the file you got from http://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl=wsdl0 somehow, you can then change the WSDL to import this local file with <wsdl:import .... location="VehicleService.xml" /> instead of what it does right now. Then you can feed this local WSDL to your client, and because now everything is in the same folder, it should work.

SOAP Client PHP Error: SOAP-ENV:Server; Procedure 'functionName' not present

i'm using a PHP client for consume a testing web service, I've written my code with the native PHP Soap client and with nusoap library, but get same error.
The response of operation is:
[faultcode] => SOAP-ENV:Server
[faultstring] => Procedure 'xxx' not present
If i use the $client->__getFunctions() it shows correctly the functions, but i don't understand the fault, in many sites recommends disable WSDL caching, but still failing with this changes.
WSDL File used, PHP code for webservice and images folder:
https://drive.google.com/open?id=0BxjxYDI011PdNzBBYlBza1VBY0E
List of functions response (no libraries):
Image name: native.png
Nusoap response (calling function):
Image name: response.png
Additionally i test that with SoapUI but get same response with this status: HTTP/1.1 500 Internal Service Error
I test that client with this webservice with no problems:
http://www.xignite.com/xquotes.asmx?WSDL
Then the code seems to be correct, but...
I need to know if my code has an error, the wsdl definition(i don't any access to server, only this file), or something else, I appreciate any information.
In response.png for your Request, your SOAPAction should point to 'getBankList', not 'http://...' (which points to the service). I'm not sure where you are setting this in the code, but the SOAPAction should point to the wsdl:service name="" value, not the actual running service.
Also, looking at the xignite WSDL, it doesn't have a getBankList function, or in fact the word 'Bank' in it at all. Are you sure you're pointing to the correct WSDL?
HTH, Jim

Nusoap library integration with codeigniter shows Unsupported HTTP response status 404 Not Found Error

I am using Nusoap library in codeigniter. My code works fine in localhost as well as on server before i make new folder for my testing purpose. But now in testing folder it gives error like this.
I'm receiving this Error:
HTTP Error: Unsupported HTTP response status 404 Not Found
(soapclient->response has contents of the response)
I have searched solution Here and Here but it shows that endpoint is not set for client. On my side, when I print my object it has the endpoint value... What do I do wrong?
I can't connect the URL(http://carvilshoe.cz.cc/index.wsdl.php?wsdl) from my web browser too. I think you have to check your WebService status is online.

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://...' in Google App Engine PHP App

I am trying to connect to Amazon Web Services from my GAE account using a simple PHP script. However, the very first line is throwing an error:
$wsdlURI = 'http://www.webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl';
$soapClient = new SoapClient($wsdlURI);
I get this error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://.....'failed to load external entity
When I do a simple file_get_contents on the above URL, it works just fine. Only the SoapClient is not able to get the handle on the wsdl file....and ONLY GAE seems to have this problem. I tried the same code on another server and everything works fine.
Is there any setting in GAE that I am missing??
This is also related to the disabling of loading of loading of external entities by default, you will need to enable this to get this to work.
First, you must create a php.ini file containing this line:
google_app_engine.enable_functions = "libxml_disable_entity_loader"
Then you add the following before your call.
libxml_disable_entity_loader(false);
For SoapClient to work using sockets application also needs to have billing enabled.
This issue is likely related: https://code.google.com/p/googleappengine/issues/detail?id=9858 .
Looks like SOAP needs sockets support, which is not yet part of the PHP runtime.
Check that you have the following extensions activated:
php open ssl
and
php soap client.

PHP SOAP Error through Proxy

i keep getting an stupid error in PHP related to SOAP which i can't solve. I've searched quite much via Google and in the official manual, but there is nothing helpful for me.
This is my problem: I got an official endpoint adress: $wsdl = example.com/wsdl, which i need to use for an soap request. The problem is that there is an proxy at my university trying to destroy all my work. So in general i need to get past my proxy, then access the wsdl file successfully and then authenticate at the web service.
What i have tried:
$wsdl = "example.com/wsdl";
$client = new SoapClient($wsdl,array('user' => 'username','password' => 'password'));
This throws the error:
"SOAP-ERROR: Parsing WSDL: Couldn't load from ... : failed to load external entity"
I also tried to cache the external wsdl file via file_get_contents by creating an valid stream with stream_context_create() which also resulted in the same error message.
How can i access this thing now? What am i doing wrong?

Categories