magento-lts icon indicating copy to clipboard operation
magento-lts copied to clipboard

SOAP fault due to "SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/' "

Open dannydnz opened this issue 9 months ago • 24 comments

Preconditions (*)

  1. https://demo.openmage.org/

Steps to reproduce (*)

  1. Run this script
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);


ini_set("soap.wsdl_cache_enabled", "0");
$api_url_v2 = 'https://demo.openmage.org/api/v2_soap/?wsdl=1';

$context = stream_context_create([
    'ssl' => [
        // set some SSL/TLS specific options
        'verify_peer' => false,
        'verify_peer_name' => false,
    ]
]);

$username = 'dummy';
$password = 'dummy';

try {
    $cli = new SoapClient( $api_url_v2, array(
        "trace"     => 1,
        "exception" => 1,
        'stream_context' => $context,
        "cache_wsdl" => WSDL_CACHE_NONE,
    ) );

    echo "Logging in..".PHP_EOL;
    $sessionId = $cli->login($username, $password);

}catch (Exception $exception){
    var_dump($exception);
}

Expected result (*)

  1. Access denied

Actual result (*)

  1. SoapFault
object(SoapFault)#2 (14) {
  ["message":protected]=>
  string(96) "SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/'"
  ["string":"Exception":private]=>
  string(0) ""
  ["code":protected]=>
  int(0)
  ["file":protected]=>
  string(58) "Openmage.php"
  ["line":protected]=>
  int(22)
  ["trace":"Exception":private]=>
  array(1) {
    [0]=>
    array(6) {
      ["file"]=>
      string(58) "Openmage.php"
      ["line"]=>
      int(22)
      ["function"]=>
      string(11) "__construct"
      ["class"]=>
      string(10) "SoapClient"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(2) {
        [0]=>
        string(45) "https://demo.openmage.org/api/v2_soap/?wsdl=1"
        [1]=>
        array(4) {
          ["trace"]=>
          int(1)
          ["exception"]=>
          int(1)
          ["stream_context"]=>
          resource(4) of type (stream-context)
          ["cache_wsdl"]=>
          int(0)
        }
      }
    }
  }
  ["previous":"Exception":private]=>
  NULL
  ["faultstring"]=>
  string(96) "SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/'"
  ["faultcode"]=>
  string(4) "WSDL"
  ["faultcodens"]=>
  NULL
  ["faultactor"]=>
  NULL
  ["detail"]=>
  NULL
  ["_name"]=>
  NULL
  ["headerfault"]=>
  NULL
}

Further investigation

curl http://schemas.xmlsoap.org/soap/encoding/

Returns a 404

dannydnz avatar May 02 '24 06:05 dannydnz


<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />

If we comment out or remove this line in all wsdl.xml and wsdl2.xml it seems to work.

Alternative is hosting the schema somewhere else and update schemaLocation to something else. i.e schemaLocation="http://somedomainthatmicrosoftdoesntbreak.xmlsoap.org/soap/encoding/"

dannydnz avatar May 02 '24 06:05 dannydnz

Confirm, this URL returns 404.

image

hirale avatar May 02 '24 08:05 hirale

Confirm, problem started a few days ago. Sometimes it works, sometimes it doesn't. I try to solve it via DNS and locally served xml(no success yet)

henrykbrzoska avatar May 02 '24 08:05 henrykbrzoska

I couldn't get it back to work by removing the statements from the wsdl.xml files. Pointing the URLs in the WSDL files to a self-hosted copy of the files also didn't help. Always got the error message "Couldn't find ...". As if the URL must always be schemas.xmlsoap.org or else it's invalid.

Now, I'm hosting http://schemas.xmlsoap.org/wsdl/soap/, http://schemas.xmlsoap.org/soap/encoding/ and http://schemas.xmlsoap.org/wdsl/ on my own server with exactly the same paths as before and aliased schemas.xmlsoap.org to my own server in the hosts file on all relevant systems (mostly ERM and CRM).

It's hacky, it's no long term solution, but it bought us some time until Microsoft get's their sh*t together (sorry) or until we can migrate over to a REST API.

Caprico85 avatar May 02 '24 12:05 Caprico85

Do we have a copy of these files? Can magento host these files instead?

pquerner avatar May 02 '24 12:05 pquerner

Where can I find these files? Is there another site where I can download them?

itsikbe avatar May 02 '24 13:05 itsikbe

There was a similar issue 2 years ago https://github.com/OpenMage/magento-lts/discussions/2223

empiricompany avatar May 02 '24 13:05 empiricompany

Do we have a copy of these files?

I took them from the Internet Archive: https://web.archive.org/web/20240228093904if_/https://schemas.xmlsoap.org/wsdl/soap/ https://web.archive.org/web/20240228093904if_/https://schemas.xmlsoap.org/soap/encoding/ https://web.archive.org/web/20240228093904if_/https://schemas.xmlsoap.org/wsdl/

Can magento host these files instead?

Not directly. To be able to replace schemas.xmlsoap.org with your own server, your server has to be respond to this domain name and it has to serve the files in this directory-like structrure as /wsdl/, /wsdl/soap/, /soap/encoding/. Magento can't build this url structure, so I modified the server config. With Caddy (https://caddyserver.com/) the rules would be:

http://schemas.xmlsoap.org {
    handle /wsdl/soap/ {
        rewrite * /var/www/foo/var/schemas/soap.xsd
        file_server
    }
    handle /soap/encoding/ {
        rewrite * /var/www/foo/var/schemas/encoding.xsd
        file_server
    }
    handle /wsdl/ {
        rewrite * /var/www/foo/var/schemas/wsdl.xsd
        file_server
    }
}

Caprico85 avatar May 02 '24 13:05 Caprico85

But magento could fix the .xml and .php files which reference that domain (http://schemas.xmlsoap.org) and replace them with a admin-controlles url instead. Then the files could be somewhere to your liking. Is that a bad idea?

pquerner avatar May 02 '24 13:05 pquerner

xsd-files-2024-05-02.zip

Added the files here from the webarchive links above, in case they disappear once more.

pquerner avatar May 02 '24 13:05 pquerner

It seems microsoft fixed the problem.

I'm not sure the domain can be switched to a custom one, somebody could test this?

fballiano avatar May 02 '24 14:05 fballiano

https://schemas.xmlsoap.org server is up now

itsikbe avatar May 02 '24 14:05 itsikbe

I also stumbled upon this. I guess this already was an issue long time ago as this import was already comented out https://github.com/OpenMage/magento-lts/blob/25fd6bb4f31d8fdbc1d687e569230c7a0b259270/app/code/core/Mage/Api/etc/wsdl.xml#L7

So i commented it out in all xml files with no obvious issues. Good to see it seems to be back online, but I think I'll keep it commented out.

/Edit: According to blame, since Magento CE 1.4.2.0

alexh-swdev avatar May 03 '24 16:05 alexh-swdev

@Flyingmana @kiatng do you think it would be safe to remove the "import" of the schema as @alexh-swdev was showing in https://github.com/OpenMage/magento-lts/issues/3968#issuecomment-2093336008?

fballiano avatar May 07 '24 10:05 fballiano

If it's safe to remove it, I prefer to avoid dependencies on external services.

Otherwise, could it be a valid and legitimate alternative if we host itself a copy of wsdl schema and changes all occurences?

like

  • https://schemas.openmage.org/wsdl/
  • https://schemas.openmage.org/wsdl/soap/
  • https://schemas.openmage.org/soap/encoding/

then change in our copy version all references like this:

<!--
 
Copyright 2001 - 2005, International Business Machines Corporation and Microsoft Corporation
All Rights Reserved

License for WSDL Schema Files

...keep the copyright...
http://schemas.xmlsoap.org/wsdl/soap/2003-02-11.xsd
THESE SCHEMA FILES ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS 
...keep the copyright...
No other rights are granted by implication, estoppel or otherwise.
-->
<xs:schema targetNamespace="http://schemas.openmage.org/wsdl/soap/">
<xs:import namespace="http://schemas.openmage.org/wsdl/"/>
<xs:simpleType name="encodingStyle">
<xs:annotation>
<xs:documentation>
"encodingStyle" indicates any canonicalization conventions followed in the contents of the containing element. For example, the value "http://schemas.openmage.org/soap/encoding/" indicates the pattern described in SOAP specification
</xs:documentation>
</xs:annotation>
<xs:list itemType="xs:anyURI"/>
</xs:simpleType>

from the copyright i read also:

Original W3C files; http://www.w3.org/2001/06/soap-encoding Changes made: - reverted namespace to http://schemas.xmlsoap.org/soap/encoding/ - reverted root to only allow 0 and 1 as lexical values - removed default value from root attribute declaration

empiricompany avatar May 07 '24 14:05 empiricompany

If you host on openmage.org you are the bottleneck. Are you sure you want to do that? If that file doesnt change, and is only there for some regulation, why not let the shop host the files? You are "talking" to the shop and they have to say how its done - not some external page?

That of course would mean some voodoo magic, since we'd have to have placeholders in these files and then switch them out somewhere early in the system (once). Last time openmage changed some XML files.. didnt work quite well iirc.

pquerner avatar May 07 '24 14:05 pquerner

(...). Last time openmage changed some XML files.. didnt work quite well iirc.

Well, it could have been better documented in the update, instead of hidden somewhere in the readme... But there's a sperate discussion about it afair ;)

Making those files part of OM would also be acceptable, I think, if removal would create issues. (But I would not host in on the OM servers). But if those really are not required... the less dependencies, the better :)

alexh-swdev avatar May 07 '24 14:05 alexh-swdev

@pquerner

If that file doesnt change, and is only there for some regulation, why not let the shop host the files?

Do you mean to create routes that respond under the same domain as the shop? But in this case, all references inside the XML definitions should be dynamic, which becomes complicated.

empiricompany avatar May 08 '24 07:05 empiricompany

Do you mean to create routes that respond under the same domain as the shop? But in this case, all references inside the XML definitions should be dynamic, which becomes complicated.

Yes, thats exactly how I mean it. Or any other domain, which could be controlled by a system configuration.

pquerner avatar May 08 '24 07:05 pquerner

if there's no need for it then let's remove it

fballiano avatar May 08 '24 07:05 fballiano

can somebody test if SOAP APIs still work if we remove all the imports?

fballiano avatar May 08 '24 12:05 fballiano

I removed the imports last week and I am using the api/v2_soap?wsdl=1 for product export with PHP clients and order import with PHP and c# clients and it looks still good...

alexh-swdev avatar May 08 '24 15:05 alexh-swdev

thanks @alexh-swdev, I've created https://github.com/OpenMage/magento-lts/pull/3980

fballiano avatar May 08 '24 15:05 fballiano

@alexh-swdev could you add a code review to https://github.com/OpenMage/magento-lts/pull/3980 pleaase?

fballiano avatar May 09 '24 11:05 fballiano

closed by #3980

fballiano avatar May 23 '24 14:05 fballiano