Error WSDL: SOAP-ERROR: Parsing WSDL: Couldn't load from - magento

My problem is very common. I read almost all topics on stackoverflow about this issue, but still can not do thing work. My code is :
ini_set("soap.wsdl_cache", "0");
ini_set("soap.wsdl_cache_enabled", "0");
$proxy = new SoapClient('http://Myhostname/api/soap?wsdl');
I had this error :
Error WSDL: SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://Myhostname/api/soap?wsdl' : failed to load external entity
"http://Myhostname/api/soap?wsdl"
In the browser the URL
http://Myhostname/api/soap?wsdl
works great (returns an xml response)
I try this code to see if PHP can reach this URL :
if (file_get_contents('http://Myhostname/api/soap?wsdl') === false) {
echo "ERROR: file_get_contents <br/>";
}
It displays me my error "ERROR: file_get_contents", so it does not work. On the forums I saw that to solve this problem I must add hostname into OS "hosts" file. So I did it. In my hosts file I added this line
127.0.0.1 Myhostname
But it still does not work. Then I changed URL in my code to
http://localhost/Myhostname/api/soap?wsdl
but it does not work either.
I tried another solution I found on the internet. For some people it worked. In my URL I changed '?' character to '.'. So my new URL became
http://localhost/Myhostname/api/soap.wsdl
but it does not work either.
I saw official SOAP doc! And tried to create SoapClient object in different way (with options like 'proxy_host' and 'proxy_port'). But this did not help me.
It's my second day I try to solve this problem, but I can not. I am doing my internship, I do not have a lot of experience, so maybe I did not try solutions I found correctly. Maybe someone can help. I would be very pleased.

Few steps to check
Have a ping to Myhostname. It would give the ip. Use ip instead and see
Check if the services are enabled
S0AP,
php_openssl,
openssl,
curl
Hope you would get it :)

I have the similar problem, I solve it uncommenting -MultiViews from .htaccess file, and later from Apache configuration of local website.
My working Apache configuration is:
<Directory /var/www/>
Options Indexes FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
You can try also url:
http://localhost/Myhostname/api.php?type=soap&wsdl
if you use community edition.

instead of $proxy = new SoapClient('http://Myhostname/api/soap?wsdl');
try $proxy = new SoapClient(WSDLFILENAME);
where WSDLFILENAME is the OS name of the WSDL file.
This has the additional benefit of making one client-server roundtrip less.

I tried the SOAP Web Services on my local host and it was working fine. The reason why the Magento was not able to give a response to the request was because it was not able to verify SSL Certificates enabled on the site.
The way I resolved it was to allow self signed SSL verification:
$opts = [
'http' =>
[
'header' => "Authorization: Bearer ".$token
],
'ssl' => [
'allow_self_signed' => true ,
'verify_peer' => false,
'verify_peer_name' => false]
];
$context = stream_context_create($opts);
I hope it helps. ;)

Related

ruby rest-client ipv6 request failure with Apache 2.2.31

I've been stuck with this for about two days...
I use ruby(version 2.3.3p222) gem rest-client(v2.0.0) to send a GET request with a ipv6 url to the server (Apache/2.2.31):
url = 'https://[fd36:4928:8040:dc10:0000:0000:0000:0160]:8080/resources/1'
resource = RestClient::Resource.new(url, :ssl_version => 'TLSv1', :verify_ssl => false, :headers => {'Authorization' => 'Basic cm9vdDAbCdEfwYXNzMSE='})
resource.get
I got a 400 bad response and the body says:"Your browser sent a request that this server could not understand. Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request"
However I can use curl command with the same parameters and get the right response, so I suspect maybe it's something wrong with the header of my rest-client request.
PS: I also tested with adding the 'host'
header: {'Authorization' => 'Basic cm9vdDAbCdEfwYXNzMSE=', 'host' => '[fd36:4928:8040:dc10:0000:0000:0000:0160]:8080' }
It still failed with the same bad response.
I just noticed the appache error for this request, it says:
"httpd[29124]: [error] Hostname fd36:4928:8040:dc10:0000:0000:0000:0160 provided via SNI and hostname fd36:4928:8040:dc10:0000:0000:0000 provided via HTTP are different
"
The curl command you supplied would translate --user admin:password into the following header:
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
However, you're sending
Basic: cm9vdDAbCdEfwYXNzMSE=
which is not the same thing... so the server is probably complaining about not getting the correct auth...
After debugging and googling for another day, this problem seems to be clear:
From a similar bug report to chrome https://bugs.chromium.org/p/chromium/issues/detail?id=500981, "SNI is only hostnames, and should never contain IPs.". However ruby does use ip as hostname (in this case rest-client is nothing to blame since it just delegate everything down to ruby lib). You can find evidence in Net::HTTP#connect (around line 922):
# Server Name Indication (SNI) RFC 3546
s.hostname = #address if s.respond_to? :hostname=
Just comment out the last line it will work (to workaround this you have to do a monkey patch). Additionally, as pointed out by #alberge, host header does not contain brackets, the final request host header is like this: "FD36:4928:8040:DC10::162", no "[ ]" around.
Also on Apache side, it does something wrong since it just strips off everything from the last colon to get the host name without any extra check- this still exists in version 2.4.10, not sure if it is fixed or not.
This appears to be either a bug in rest-client or a regression in Ruby Net::HTTP.
https://github.com/rest-client/rest-client/issues/583
What version of Ruby are you using? Have you tried using Ruby 2.1 to see if it works there?
EDIT:
This is Ruby Bug #12642. The Host header for an IPv6 address is sent with no enclosing [ ].
Ruby in 2.1.6 - 2.1.10 doesn't have the bug, but versions >= 2.2.0 are affected.
And worse still, there's a bug with setting an explicit IPv6 Host header so you get an exception URI::InvalidComponentError: bad component(expected host component): [

Deprecated: mysql_connect() message and Warnings occur in step 3 of the opencart configuration setup after we enter the details and hit continue

We need help trying to upload our opencart templatemonster.com template correctly on godaddy but we are not clear on how to do that.
FYI our public_html/system/database folder contains a mysqli.php file as well.
We made sure to upload the template via fullpackage (The name of the file is themeXXX(full).zip, where XXX is your theme number) to the public_html folder.
Extracted the zip files in the public_html folder.
Performed the installation using the installation manager .
At step 3 configuration we were prompted to input our database access details and made sure the database was empty. (GoDaddy told us to use the localhost)
After hitting continue:
The deprecated: mysql_connect() message and Warnings occur in step 3 of the opencart configuration setup after we enter the details and hit continue.
Where ‘store’ is the new directory name. Where ‘user’ is your server
account address. Where ‘yourdomainname.co.uk’ is the web domain of
your new website:
(DUMMY LINK FOR DEMONSTRATION PURPOSES) http://www.yourdomainname.co.uk/install/index.php?route=step_3
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/user /public_html/system/database/mysql.php on line 6
Lines 5-16:
public function __construct($hostname, $username, $password, $database) {
if (!$this->link = mysql_connect($hostname, $username, $password)) {
trigger_error('Error: Could not make a database link using ' . $username . '#' . $hostname);
}
if (!mysql_select_db($database, $this->link)) {
trigger_error('Error: Could not connect to database ' . $database);
}
Errors:
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/system/database/mysql.php:6) in /home/user/public_html/system/engine/controller.php on line 28
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/system/database/mysql.php:6) in /home/user/public_html/system/engine/controller.php on line 29
Lines 27-31
protected function redirect($url, $status = 302) {
header('Status: ' . $status);
header('Location: ' . str_replace(array('&', "\n", "\r"), array('&', '', ''), $url));
exit();
}
Template Features
OpenCart Compatibility: 1.5.6.x
OpenCart Engine: 1.5.6.4
(Trimmed)
Sources Available
PSD PNG PHP TPL JS
Hosting Requirements
Web Server (preferably Apache)
PHP (at least 5.2)
MySQL
Curl
Fsock
OpenCart Templates Help Center
Software Required
Adobe Photoshop CS+
For uncompressing a template ZIP package: WinZip 9+ (Windows);
Stuffit Expander 10+ (Mac)
Apache Server
PHP v. 5 or higher
MySQL 4.1.14 or later
OpenCart 1.5.6.4
Sublime Text2 or later, Notepad++ or any php-editor
A commenter stated
mysql_ calls will work on this server but are causing deprecation
notices. A quick fix would be to turn off warnings in your php.ini
file, in your error_reporting value. Or you could try turning off
display errors, set display_errors to 0.
I like the comment but could someone provide a slightly more comprehensive explanation or visual resource to this suggestion? Such as articulating a little further how to proceed? Should I download the file through GoDaddys public FTP or should I use FileZilla FTP client (does it matter), make a copy, make the proper changes then re-upload?
I like the possible solution but I am curious to know if these are the only ones.
UPDATE
I just changed display_errors = 1; to display_errors = 0;
saved the file (I edited the file withing GoDaddy's text editor)
re-input our database access details
hit continue on step 3 configuration and got the same error.
php.ini
magic_quotes_gpc = Off;
register_globals = Off;
default_charset = UTF-8;
memory_limit = 64M;
max_execution_time = 36000;
upload_max_filesize = 999M;
safe_mode = Off;
mysql.connect_timeout = 20;
session.use_only_cookies = On;
session.use_trans_sid = Off;
session.cookie_httponly = On;
session.gc_maxlifetime = 172800;
allow_url_fopen = on;
;display_errors = 0;
;error_reporting = E_ALL;
???
I have a similar experience! You don't need to enable these extensions the PHP Version needs to be update:
Sign into GoDaddy
Go to My Products under your sign in name at the top right.
Go to Web Hosting and click the Manage button.
Click manage again.
Scroll to the Software header and click "Select PHP Version"
Then change to an earlier version, in which this extension is not deprecated.
Let me know how that works for you.

Rails 3.2 xsendfile not working

I have to download static files which need authentication.
I am following http://makandracards.com/makandra/990-speed-up-file-downloads-with-rails-apache-and-x-sendfile and https://tn123.org/mod_xsendfile/
I have set config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache in production.rb
Controller:
send_file("#{Rails.root}/private/myfile.mp3",
:filename => "myfile.mp3",
type: "audio/mpeg",
:disposition => 'inline')
Apache configuration:
<VirtualHost _default_:80>
ServerName myserver.com
RequestHeader Set X-Sendfile-Type X-Sendfile
XSendFile On
XSendFilePath /sites/releases
RailsEnv production
</VirtualHost>
Even though, I put this, it is not sending any x-sendfile header.
It is strange but if I remove X-Sendfile On and X-SendfilePath, then it sets X-Sendfile header but the file does not play in browser.
I am trying this for three days, I have read everything available on google.
I have a feeling I'm missing something simple. If anyone has any suggestions, please let me
know!
Thanks.

Omniauth authentication fails in Rails 4

I am working in rails 4 and I am trying to authenticate using github. So in my Github application I have this:
URL: http:// localhost:4000
Callback URL: http:// localhost:4000/auth/github/callback
The callback url is the url that Github will try to reach when the authentication is done right?
So why do I get a Github page 404 error when I click on my link:
<%= link_to 'Sign in with Github', '/auth/github' %>
I am working on a localhost development enviroment so that might be the problem?
Also when i type http:// localhost:4000/auth/github/callback on my browser I get an OmniAuth::Strategies::OAuth2::CallbackError
why? I have this in my routes.rb
post 'auth/:provider/callback' => 'home#index'
Is Rails 4 and Omniauth bugged?
(added the space in localhost so stackoverflow accepts my post)
I have github working with the gem omniauth-github
and a file config/initializers/omniauth.rb containing
Rails.application.config.middleware.use OmniAuth::Builder do
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET']
end
However, when I enter http://localhost:3000/auth/github/callback on my browser I also get OmniAuth::Strategies::OAuth2::CallbackError so this shouldn't be the problem.
My config/environment.rb looks like
# Load the rails application
require File.expand_path('../application', __FILE__)
# Load the app's custom environment variables here, so that they are loaded before environments/*.rb
app_environment_variables = File.join(Rails.root, 'config', 'app_environment_variables.rb')
load(app_environment_variables) if File.exists?(app_environment_variables)
...
and my config/app/environment_variables.rb looks like
# OAuth Keys and Secrets
if Rails.env.production?
ENV['GITHUB_KEY'] = 'd1234a3a123a1a3a123c'
ENV['GITHUB_SECRET'] = '1234azer123azer1231209jeunsghezkndaz1234'
else
ENV['GITHUB_KEY'] = 'qsflkjkj685bg554456b'
ENV['GITHUB_SECRET'] = 'qslkfj7757kqfmlsdh675hlfsd587kjfdh687jsd'
end
See Is it possible to set ENV variables for rails development environment in my code? for more details on that.
I have 2 applications registered on github. One app_name-dev with key qsflk..., url http://localhost:3000 and callback url http://localhost:3000/auth/github/callback and one app_name with key d1234a....
Check that you have done that correctly. Maybe try to change localhost to 127.0.0.1.
For me it was Github's new stricter URI matching that was producing a 404 when trying to redirect to http://localhost:3000/auth/github/callback, I solved it by passing the redirect URI as a parameter with Omniauth.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'],
:scope => 'user,public_repo',
:redirect_uri => ENV['GITHUB_REDIRECT']
end
If your on Linux/Mac you can add environment variables from the command line.
$ export GITHUB_REDIRECT=http://localhost:3000/auth/github/callback
Alternatively, you could use something like Foreman that will let you add a .env file which you can use to store your variables in.
Just remember to add the appropriate redirect URI to your production environment's variables, and you're good, to go.

CKeditor & KCFinder in localhost

I am a building a website locally and I am using CKeditor with KCFinder at a part of it. CKEditor runs properly and KCFinder Upload Tab is also visible, so I guess my installation was correct.
BUT! When I try to upload an image using the KCFinder module ("Browse" then "Send to server") I get an error message showing in the same popped-up window saying:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
03/01/12 14:31:05
Apache/2.2.21 (Win32) PHP/5.3.8
I have Windows 7, running it in localhost with Easy PHP and the local path to my target folder is:
C:\PROGRA~2\EASYPH~2.1\www\electro\kcfinder\upload
In my kcfinder/config.php I have:
'uploadURL' => "/upload",
'uploadURL' => "../upload",
'uploadDir' => "",
'uploadDir' => "C:\PROGRA~2\EASYPH~2.1\www\electro\kcfinder\upload",
as instructed by the official related thread here.
Anyone has any idea what might be wrong?
EDIT:
Solved it. Needed to change the paths on both KCFinder/config.php AND CKEditor/config.js. Since my paths are:
The project path:
C:\PROGRA~2\EASYPH~2.1\www\electro
and it has the subfolders "ckeditor" and "kcfinder" and I want to have the folder "kcfinder/upload" as the target folder of the filed to be uploaded, then the following changes need to made...
ckeditor/config.js:
CKEDITOR.editorConfig = function(config) {
config.filebrowserBrowseUrl = '../electro/kcfinder/browse.php?type=files';
config.filebrowserImageBrowseUrl = '../electro/kcfinder/browse.php?type=images';
config.filebrowserFlashBrowseUrl = '../electro/kcfinder/browse.php?type=flash';
config.filebrowserUploadUrl = '../electro/kcfinder/upload.php?type=files';
config.filebrowserImageUploadUrl = '../electro/kcfinder/upload.php?type=images';
config.filebrowserFlashUploadUrl = '../electro/kcfinder/upload.php?type=flash';
};
kcfinder/config.php:
'uploadURL' => "upload",
'uploadDir' => "",
For some reason it needed the ../ while it was already in the same folder. I don't understand why, but it works.
Now, I would like to say how displeased I am at the developer of the KCFinder where people with the same issue or others on its support forum the given "help" was things like "RTFM", "Do better searches" etc. As if everyone was born an experienced programmer.
I actually found the answer shortly after I posted my answer. It seems that the path system on ckeditor/config.js doesn't really work as a normal path usually works. so, you have to play around with the "../" and try to find out where it is aiming at. In my case, I didn't need any "../" to refer to a file that was in a separated folder one level up. So the final code for me was:
CKEDITOR.editorConfig = function(config) {
config.filebrowserBrowseUrl = 'kcfinder/browse.php?type=files';
config.filebrowserImageBrowseUrl = 'kcfinder/browse.php?type=images';
config.filebrowserFlashBrowseUrl = 'kcfinder/browse.php?type=flash';
config.filebrowserUploadUrl = 'kcfinder/upload.php?type=files';
config.filebrowserImageUploadUrl = 'kcfinder/upload.php?type=images';
config.filebrowserFlashUploadUrl = 'kcfinder/upload.php?type=flash';
};
when actually should be '../kcfinder/browse.php?type=files'
Hope it helps...

Resources