Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
849 views
in Technique[技术] by (71.8m points)

magento - Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't 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/'

First, I am sorry to say I put these question here cause so many same question in stackoverflow. But it seems not any fit for me.

I use Magento SOAP2 API for times, this error not happed often. But it keeps make a fatal error when I run my script today.

I have looked up 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 this

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

I followed this, but it make another error like below,

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

Then I have no idea what's wrong, cause this script is always running perfectly but today and I even do not change any line of the code. My question is, 1, Any method to solve it? 2, Can I make this xmlsoap.org xml file to localhost or my own server so that my script will not depend on a file out my server.

Thank you in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First of all, please never tamper with the default elements of any Magento API V2 WSDL Configuration file. It's a basic rule.

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

  1. "definition" element (<definitions> - start tag)
  2. "types" element (<types> - start tag)
  3. "schema" element (<schema> - start tag)
  4. "import" element (<import /> - singleton tag, with no end tag)

Then you can continue with defining the Complex Data Types of the Magento API V2 for that Custom Module.

You can very well get the concept of all these by looking into some of the existing Magento API V2 WSDL files.


Now coming back to your questions...

1. Any method to solve it? As I said before, please maintain the above-mentioned elements definitions at the beginning 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/" />
with no end tag. Also the attribute name is "schemaLocation" & not "schemalocation". Follow the Camel Casing please.


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

Yes you can, but you need to know & maintain two vital points:-

  1. Both of the attributes "namespace" & "schemaLocation" must be of type URI, according to the W3C specifications. So your local files for both of these attributes must also be accessible in your local browser, using HTTP protocol.
  2. If you are maintaining it in your local hard disk, then you are forgetting about one golden rule of upgradation, for Schema of the SOAP/1.1 encoding file. This is because if (only if) W3C upgrades this file in this same URI, then your Magento will be able to take it automatically if the general URI is provided; otherwise you will need to download that upgraded file again to your server.

Other than these two major points, everything is okay & you are good to go.


Nevertheless, I hope that I have answered all your queries. Hope it helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...