function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
agabagab 

Referencing external schemas in a WSDL

Hello,
I am getting the following error when trying to parse a WSDL and generate the relevant Apex classes in SalesForce:
 
"Error: Failed to parse wsdl: Found schema import from location https://*.xsd. External schema import not supported."
 
I believe that the following (edited) section of the WSDL referring to an external schema is what's causing the problem:
 
...

<wsdl:types>

<xs:schema>

<xs:import namespace="" schemaLocation="https://*.xsd"/>

</xs:schema>

<xs:schema>

<xs:import namespace="" schemaLocation="https://*.xsd"/>

</xs:schema>

</wsdl:types>

...

Can anyone confirm that this is in fact not allowed by Salesforce and if there is any remedy other than embedding the schema in the WSDL?

 
Thanks,
agab-
Best Answer chosen by Admin (Salesforce Developers) 
Seb OrtizSeb Ortiz

Hi,

 

I had to deal with an WSDL with external schemas which they also import other schemas. It was a mess at first but the solution was easier than I thought.

 

1. Open the WSDL with a text editor
2. Inside <wsdl:types> (below the last <schema>) paste each referenced .xsd file content. Paste only <schema></schema>
3. Once all schemas are in the WSDL then comment all <xsd:import> using <!-- -->. They are no longer needed.
4. Save and you are ready to go.

 

Some of my classes returned compiling errors because of Exception classes that must extend the Salesforce Exception class. So copy the generated class, correct it into a text editor and then created manually as after clicking "Done", changes are not reprocessed.


Regards,
Sebastian

All Answers

SuperfellSuperfell
Right, xsd:import and wsdl:import are not supported (as the error message indicates). the only solution it to re-work the wsdl to have all the imported schemas in the wsdl document directly.
agabagab
Ok, thanks for confirming.
agab-
WhyserWhyser

I'm a newb, can you or someone explain or show me to me how to

 

"re-work the wsdl to have all the imported schemas in the wsdl document directly." ??

 

 

Seb OrtizSeb Ortiz

Hi,

 

I had to deal with an WSDL with external schemas which they also import other schemas. It was a mess at first but the solution was easier than I thought.

 

1. Open the WSDL with a text editor
2. Inside <wsdl:types> (below the last <schema>) paste each referenced .xsd file content. Paste only <schema></schema>
3. Once all schemas are in the WSDL then comment all <xsd:import> using <!-- -->. They are no longer needed.
4. Save and you are ready to go.

 

Some of my classes returned compiling errors because of Exception classes that must extend the Salesforce Exception class. So copy the generated class, correct it into a text editor and then created manually as after clicking "Done", changes are not reprocessed.


Regards,
Sebastian

This was selected as the best answer
eclfeclf

Hello,

 

I'm having this same problem and I was trying to follow your instructions to solve this, but I gotta confess I'm not being successful AT ALL!

 

So can I ask for you to please add some code sample to your post? It would be incredibely helpful and greatly appreciated.

 

Thank you in advance.

 

EF

Seb OrtizSeb Ortiz

Hi, try to paste here a short version of your wsdl and one of the referenced .xsd files.

 

I'll see if I can help

 

Regards

eclfeclf

Hi, thanks for the fast reply. 

 

I think (!!) I almost got it, but nevertheless, won't hurt to use some expert help.

 

Here is part of my wsdl:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://www.softlimits.com/Netdocs" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="CNDEntityService" targetNamespace="http://www.softlimits.com/Netdocs">
<wsp:Policy wsu:Id="WSHttpBinding_ICNDEntityService_policy">...</wsp:Policy>
<wsp:Policy wsu:Id="BasicHttpBinding_ICNDEntityService_policy">...</wsp:Policy>
<wsdl:types>
<xsd:schema targetNamespace="http://www.softlimits.com/Netdocs/Imports">
<xsd:import schemaLocation="https://e2e.gs1pt.org/Gs1SyncPTe2e/CNDEntityService.svc?xsd=xsd0" namespace="http://www.softlimits.com/Netdocs"/>

...
</xsd:schema>
</wsdl:types>

...

 And here is the .xsd: https://e2e.gs1pt.org/Gs1SyncPTe2e/CNDEntityService.svc?xsd=xsd0

 

Do I have to replace the <xsd:import> for the whole xs:schema? That's it? 

 

Thanks again.

 

EF

Seb OrtizSeb Ortiz

No, try by commenting the xsd:import and paste the whole xsd file content below the last <xsd:schema>

If it does not make it, try replacing the xsd:import with the referenced file content.

 

See below my idea

Let me know how it goes

 

Regards

 

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://www.softlimits.com/Netdocs" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="CNDEntityService" targetNamespace="http://www.softlimits.com/Netdocs">
<wsp:Policy wsu:Id="WSHttpBinding_ICNDEntityService_policy">...</wsp:Policy>
<wsp:Policy wsu:Id="BasicHttpBinding_ICNDEntityService_policy">...</wsp:Policy>
<wsdl:types>
<xsd:schema targetNamespace="http://www.softlimits.com/Netdocs/Imports">
    <!--
<xsd:import schemaLocation="https://e2e.gs1pt.org/Gs1SyncPTe2e/CNDEntityService.svc?xsd=xsd0"
namespace="http://www.softlimits.com/Netdocs"/>
--> ... </xsd:schema>

<!-- CONTENT FROM YOUR XSD FILE -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.softlimits.com/Netdocs" elementFormDefault="qualified"targetNamespace="http://www.softlimits.com/Netdocs">
</xs:schema>

</wsdl:types> ...
eclfeclf

Ok, so I did this:

<wsdl:types>
<xsd:schema targetNamespace="http://www.softlimits.com/Netdocs/Imports">
<!--
<xsd:import schemaLocation="https://e2e.gs1pt.org/Gs1SyncPTe2e/CNDEntityService.svc?xsd=xsd0" namespace="http://www.softlimits.com/Netdocs"/>
<xsd:import schemaLocation="https://e2e.gs1pt.org/Gs1SyncPTe2e/CNDEntityService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="https://e2e.gs1pt.org/Gs1SyncPTe2e/CNDEntityService.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
-->
</xsd:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.softlimits.com/Netdocs" elementFormDefault="qualified" targetNamespace="http://www.softlimits.com/Netdocs">
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
</xs:schema>
</wsdl:types>

And I got another error:

Error: Failed to parse wsdl: Found more than one wsdl:binding. WSDL with multiple binding not supported
 
:(
 
Thanks for the help.

 

EF

Seb OrtizSeb Ortiz
Oh, ok. For that, just browse your wsdl for the bindings definitions and comment the one that looks like soapbinding12 or similar, and keep the other one. Save and try again. Regards, Sebastian
eclfeclf

Hi Sebastian,

 

It worked! I'm having other problems, but you know... I'll figure it out. 

 

Thank you very so much for you time and help. It was greatly appreciated. 

 

Best regards,

EF

Seb OrtizSeb Ortiz
Great! I'm glad it worked :) Regards
Rajesh chRajesh ch
Hi Seba,

I am having same issue with parsing WSDL2APEX,

here is my wsdl, can you please look into this once and can you guide me for the solution

Error: Failed to parse wsdl: Found schema import from location http://122.181.153.203/SFDC/CL_MainService.svc?xsd=xsd0. External schema import not supported



<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="CL_MainService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://122.121.193.283/SFDC/CL_MainService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://122.121.193.283/SFDC/CL_MainService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="CL_MainService_set_Username_InputMessage">
<wsdl:part name="parameters" element="tns:set_Username"/>
</wsdl:message>
<wsdl:message name="CL_MainService_set_Username_OutputMessage">
<wsdl:part name="parameters" element="tns:set_UsernameResponse"/>
</wsdl:message>
<wsdl:message name="CL_MainService_set_Password_InputMessage">
<wsdl:part name="parameters" element="tns:set_Password"/>
</wsdl:message>
<wsdl:message name="CL_MainService_set_Password_OutputMessage">
<wsdl:part name="parameters" element="tns:set_PasswordResponse"/>
</wsdl:message>
<wsdl:message name="CL_MainService_set_CustomerCode_InputMessage">
<wsdl:part name="parameters" element="tns:set_CustomerCode"/>
</wsdl:message>
<wsdl:message name="CL_MainService_set_CustomerCode_OutputMessage">
<wsdl:part name="parameters" element="tns:set_CustomerCodeResponse"/>
</wsdl:message>
<wsdl:message name="CL_MainService_set_PropertyCode_InputMessage">
<wsdl:part name="parameters" element="tns:set_PropertyCode"/>
</wsdl:message>
<wsdl:message name="CL_MainService_set_PropertyCode_OutputMessage">
<wsdl:part name="parameters" element="tns:set_PropertyCodeResponse"/>
</wsdl:message>
<wsdl:message name="CL_MainService_WS_GetSalesOffice_InputMessage">
<wsdl:part name="parameters" element="tns:WS_GetSalesOffice"/>
</wsdl:message>
<wsdl:message name="CL_MainService_WS_GetSalesOffice_OutputMessage">
<wsdl:part name="parameters" element="tns:WS_GetSalesOfficeResponse"/>
</wsdl:message>
<wsdl:message name="CL_MainService_WS_GetSalesExecutives_InputMessage">
<wsdl:part name="parameters" element="tns:WS_GetSalesExecutives"/>
</wsdl:message>
<wsdl:message name="CL_MainService_WS_GetSalesExecutives_OutputMessage">
<wsdl:part name="parameters" element="tns:WS_GetSalesExecutivesResponse"/>
</wsdl:message>
<wsdl:message name="CL_MainService_WS_CollectionExecutives_InputMessage">
<wsdl:part name="parameters" element="tns:WS_CollectionExecutives"/>
</wsdl:message>
<wsdl:message name="CL_MainService_WS_CollectionExecutives_OutputMessage">
<wsdl:part name="parameters" element="tns:WS_CollectionExecutivesResponse"/>
</wsdl:message>
<wsdl:portType name="CL_MainService">
<wsdl:operation name="set_Username">
<wsdl:input wsaw:Action="http://tempuri.org/CL_MainService/set_Username" message="tns:CL_MainService_set_Username_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/CL_MainService/set_UsernameResponse" message="tns:CL_MainService_set_Username_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="set_Password">
<wsdl:input wsaw:Action="http://tempuri.org/CL_MainService/set_Password" message="tns:CL_MainService_set_Password_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/CL_MainService/set_PasswordResponse" message="tns:CL_MainService_set_Password_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="set_CustomerCode">
<wsdl:input wsaw:Action="http://tempuri.org/CL_MainService/set_CustomerCode" message="tns:CL_MainService_set_CustomerCode_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/CL_MainService/set_CustomerCodeResponse" message="tns:CL_MainService_set_CustomerCode_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="set_PropertyCode">
<wsdl:input wsaw:Action="http://tempuri.org/CL_MainService/set_PropertyCode" message="tns:CL_MainService_set_PropertyCode_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/CL_MainService/set_PropertyCodeResponse" message="tns:CL_MainService_set_PropertyCode_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="WS_GetSalesOffice">
<wsdl:input wsaw:Action="http://tempuri.org/CL_MainService/WS_GetSalesOffice" message="tns:CL_MainService_WS_GetSalesOffice_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/CL_MainService/WS_GetSalesOfficeResponse" message="tns:CL_MainService_WS_GetSalesOffice_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="WS_GetSalesExecutives">
<wsdl:input wsaw:Action="http://tempuri.org/CL_MainService/WS_GetSalesExecutives" message="tns:CL_MainService_WS_GetSalesExecutives_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/CL_MainService/WS_GetSalesExecutivesResponse" message="tns:CL_MainService_WS_GetSalesExecutives_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="WS_CollectionExecutives">
<wsdl:input wsaw:Action="http://tempuri.org/CL_MainService/WS_CollectionExecutives" message="tns:CL_MainService_WS_CollectionExecutives_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/CL_MainService/WS_CollectionExecutivesResponse" message="tns:CL_MainService_WS_CollectionExecutives_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_CL_MainService" type="tns:CL_MainService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="set_Username">
<soap:operation soapAction="http://tempuri.org/CL_MainService/set_Username" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="set_Password">
<soap:operation soapAction="http://tempuri.org/CL_MainService/set_Password" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="set_CustomerCode">
<soap:operation soapAction="http://tempuri.org/CL_MainService/set_CustomerCode" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="set_PropertyCode">
<soap:operation soapAction="http://tempuri.org/CL_MainService/set_PropertyCode" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="WS_GetSalesOffice">
<soap:operation soapAction="http://tempuri.org/CL_MainService/WS_GetSalesOffice" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="WS_GetSalesExecutives">
<soap:operation soapAction="http://tempuri.org/CL_MainService/WS_GetSalesExecutives" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="WS_CollectionExecutives">
<soap:operation soapAction="http://tempuri.org/CL_MainService/WS_CollectionExecutives" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CL_MainService">
<wsdl:port name="BasicHttpBinding_CL_MainService" binding="tns:BasicHttpBinding_CL_MainService">
<soap:address location="http://122.121.193.283/SFDC/CL_MainService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Kota Uday 6Kota Uday 6
Hi  SebaOrtiz,I am getting this error on my WSDL youd you please help me to resolve it,


Error: Failed to parse wsdl: Parse error: Found invalid XML. start tag not allowed in epilog but got d (position: END_TAG seen ...ProductPriceInquiry/2013-02-11/productpriceinquiry_V2"/>-->\r\n\t\t\t
Ravi Benedetti 7Ravi Benedetti 7
http://ravibenedetti.blogspot.com/2018/05/salesforce-apex-generate-from-wsdl_15.html