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
ThomasTTThomasTT 

WSDL2APEX Parse error - Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}string

This is actually a confirmation to SFDC (so if some God in the SFDC heaven or any other wild heaven is watching me, please answer to my question...)

I got an parse error when I tried to generate apex class from WSDL by WSDL2APEX.

 

Error: Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}string

like this post: http://community.salesforce.com/sforce/board/message?board.id=general_development&message.id=28929

Long story in short, I found the reason. Request/Response message doesn't accept just a xsd:string. It has to be complexType.

This post

http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=2058

mentioned that SFDC doesn't support simpleType restriction, but I wonder it also mens it doesn't support single-standard type Request/Response.

 

Question: Am I correct? which means there is no way to use this WSDL? (this WSDL is from a product, so I can't change the actual format... only way to use this is to create a custom HTTP request...)

 

So, this doesn't work, because SessionID is xsd:string.

<definitions xmlns:tns="http://www.hoge.com/hoge/Object"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="Companies"
targetNamespace="http://www.hoge.com/hoge/Object">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://www.hoge.com/hoge/Object">
<xsd:element name="Login">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" name="Username" type="xsd:string"/>
<xsd:element minOccurs="0" name="Password" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SessionID" type="xsd:string"/>
</xsd:schema>
</types>
<message name="Login">
<part element="tns:Login" name="parameters"/>
</message>
<message name="LoginResponse">
<part element="tns:SessionID" name="body"/>
</message>

<portType name="CompaniesPort">
<operation name="Login">
<input message="tns:Login"/>
<output message="tns:LoginResponse"/>
</operation>
</portType>
<binding name="CompaniesSoapBinding" type="tns:CompaniesPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Login">
<soap:operation soapAction="https://morethan/foo/bar/Login" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CompaniesService">
<port binding="tns:CompaniesSoapBinding" name="CompaniesService">
<soap:address location="https://morethan/foo/bar"/>
</port>
</service>
</definitions>

 This works because LoginOut is complexType.

<definitions xmlns:tns="http://www.hoge.com/hoge/Object"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="Companies"
targetNamespace="http://www.hoge.com/hoge/Object">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://www.hoge.com/hoge/Object">
<xsd:element name="Login">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" name="Username" type="xsd:string"/>
<xsd:element minOccurs="0" name="Password" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="LoginOut">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="SessionID" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>
</types>
<message name="Login">
<part element="tns:Login" name="parameters"/>
</message>
<message name="LoginResponse">
<part element="tns:LoginOut" name="body"/>
</message>
<portType name="CompaniesPort">
<operation name="Login">
<input message="tns:Login"/>
<output message="tns:LoginResponse"/>
</operation>
</portType>
<binding name="CompaniesSoapBinding" type="tns:CompaniesPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Login">
<soap:operation soapAction="https://morethan/foo/bar/Login" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CompaniesService">
<port binding="tns:CompaniesSoapBinding" name="CompaniesService">
<soap:address location="https://morethan/foo/bar"/>
</port>
</service>
</definitions>
ThomasTT
Anup JadhavAnup Jadhav
The alternative is to create the soap request using http webservice methods in apex. The downside is that you would have to handcraft the soap request and handle the soap response manually, which can be tedious initially.