Fatal error: throw exception SoapFault: [WSDL] SOAP-ERROR: schema Parsing: cannot import schema from 'http://schemas.xmlsoap.org/soap/encoding/'

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/' 

Firstly, I am sorry that I posed this question here, causing as many questions in stackoverflow. But it seems to me that this is not suitable for me.

I use the Magento SOAP2 API for times, this error often failed. But he continues to make a fatal mistake when I run my script today.

I was looking for some method to solve this problem, for example, some articles told me to change this code in /app/code/core/Mage/Api/etc/wsdl.xml

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

to that

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

I followed this, but he made another mistake, as shown below,

 Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected <import> in schema 

Then I have no idea what happened, because this script always works fine, but today, and I don’t even change a single line of code. My question is 1, Any method to solve it? 2, Can I make this xmlsoap.org xml file on localhost or on my own server so that my script does not depend on my server file.

Thank you in advance!

+2
source share
3 answers

First of all, never interfere with the default elements of any Magento API V2 WSDL configuration file. This is a basic rule.

Please keep in mind to write these following elements at the beginning of each user-defined WSDL file or make sure that these following elements are present at the beginning of the WSDL file of your target existing module: -

  • " definition " ( <definitions> - start tag)
  • " types " ( <types> - start tag)
  • " schema " ( <schema> - start tag)
  • " import " ( <import /> - singleton tag without end tag)

You can then continue to define complex Magento API V2 data types for this custom module.

You can very well understand all these concepts by looking at some of the existing Magento API V2 WSDL files.


Now back to your questions ...

1. Any method for solving it? As I said before, save the above element definitions at the top of your WSDL file.

The import statement should have been: -
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
without end tag. Also, the attribute name is " schemaLocation ", not " schemaLocation ". Follow the Camel case.


2. Can I make this xmlsoap.org xml file on localhost or on my own server so that my script does not depend on a file on my server?

Yes, you can, but you need to know and support two important points: -

  • Both the " namespace " and " schemaLocation " schemaLocation must have a type URI, in accordance with the W3C specifications. Therefore, your local files for both of these attributes must also be accessible in your local browser using the HTTP protocol.
  • If you support it on your local hard drive, you forget about one golden update rule for the SOAP / 1.1 encoding file scheme. This is because if (only if) the W3C updates this file in the same URI, then your Magento will be able to accept it automatically if a common URI is provided; otherwise, you will need to upload this updated file to your server again.

Beyond these two highlights, everything is fine and you are good to go.


However, I hope that I answered all your inquiries. Hope this helps.

+2
source

Use code like

// create a soap object

 `$proxy = new SoapClient('http://localhost/magento/index.php/api/soap/?wsdl');` 

// create an authorized session id using api username and api key

 $sessionId = $proxy->login('apiUser', 'apiKey'); $productinfo = $proxy->call($sessionId, 'product.info',16); echo "<pre>";print_r($productinfo); 
0
source

Only some details for the decision made.

  • Enter the address of the location of the scheme in the browser:

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

  • Save the XML result in a browser in a file called encoding.xsd (save the file as).

  • Copy this file to the magento root directory, for example. /var/www/magento/
  • Search for all schema entries in the wsd * .xml directory from the root magento folder, for example.
    find . -name "wsdl*.xml" | xargs grep schemaLocation 2>/dev/null | grep org
    My system has 12 matching files in. / app / code / core and 2 matching files from third-party extensions in. / app / code / local.
  • Change the line in each xml file being mapped

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

    Note In this case, the encoding.xsd file contains 4 directories with higher reliance on the api path http://sampleshop.com/testsystem/index.php/api/v2_soap/?wsdl
    On your living system, 2 (without index.php) or 3 (with index.php) times "../" may be correct.

  • Try SOAP calls from local and remote server
    Script Example
    <?php $proxy = new SoapClient('http://sampleshop.com/testsystem/index.php/api/v2_soap/?wsdl'); $sessionId = $proxy->login('MagentoSoapUser', 'SoapApiKey'); $result = $proxy->directoryCountryList($sessionId); var_dump($result); ?>

    These solutions worked for me, just wanted to add some details, since it took me some time to get it running.
    System: magento CE 1.7.0.2
    SOAP: php-soap with php version 5.3 on the magento server and 5.6 on the remote server.

Kozure

0
source

Source: https://habr.com/ru/post/1392938/


All Articles