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
sushil77sushil77 

Not able to Generate the Class from WSDL

I am  trying to generate class from following wsdl but it is reflecting error

" Unable to find complexType for {http://soap.sforce.com/schemas/class/CTSWebService}User "

 

 part1:

 

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Web Services API : CTSWebService
-->
<definitions targetNamespace="http://soap.sforce.com/schemas/class/CTSWebService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.sforce.com/schemas/class/CTSWebService">
 <types>
  <xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/CTSWebService">
   <xsd:element name="DebuggingInfo">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="debugLog" type="xsd:string"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:simpleType name="ID">
    <xsd:restriction base="xsd:string">
     <xsd:length value="18"/>
     <xsd:pattern value="[a-zA-Z0-9]{18}"/>
    </xsd:restriction>
   </xsd:simpleType>
   <xsd:simpleType name="LogCategory">
    <xsd:restriction base="xsd:string">
     <xsd:enumeration value="Db"/>
     <xsd:enumeration value="Workflow"/>
     <xsd:enumeration value="Validation"/>
     <xsd:enumeration value="Callout"/>
     <xsd:enumeration value="Apex_code"/>
     <xsd:enumeration value="Apex_profiling"/>
     <xsd:enumeration value="Visualforce"/>
     <xsd:enumeration value="System"/>
     <xsd:enumeration value="All"/>
    </xsd:restriction>
   </xsd:simpleType>
   <xsd:simpleType name="LogCategoryLevel">
    <xsd:restriction base="xsd:string">
     <xsd:enumeration value="Internal"/>
     <xsd:enumeration value="Finest"/>
     <xsd:enumeration value="Finer"/>
     <xsd:enumeration value="Fine"/>
     <xsd:enumeration value="Debug"/>
     <xsd:enumeration value="Info"/>
     <xsd:enumeration value="Warn"/>
     <xsd:enumeration value="Error"/>
    </xsd:restriction>
   </xsd:simpleType>
   <xsd:complexType name="LogInfo">
    <xsd:sequence>
     <xsd:element name="category" type="tns:LogCategory"/>
     <xsd:element name="level" type="tns:LogCategoryLevel"/>
    </xsd:sequence>
   </xsd:complexType>
   <xsd:simpleType name="LogType">
    <xsd:restriction base="xsd:string">
     <xsd:enumeration value="None"/>
     <xsd:enumeration value="Debugonly"/>
     <xsd:enumeration value="Db"/>
     <xsd:enumeration value="Profiling"/>
     <xsd:enumeration value="Callout"/>
     <xsd:enumeration value="Detail"/>
    </xsd:restriction>
   </xsd:simpleType>

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

sushil77sushil77

part2:

 

 <xsd:element name="DebuggingHeader">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="categories" minOccurs="0" maxOccurs="unbounded" type="tns:LogInfo"/>
      <xsd:element name="debugLevel" type="tns:LogType"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:element name="CallOptions">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="client" type="xsd:string"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:element name="SessionHeader">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="sessionId" type="xsd:string"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:element name="AllowFieldTruncationHeader">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="allowFieldTruncation" type="xsd:boolean"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:complexType name="QueryResult">
    <xsd:sequence>
     <xsd:element name="done" type="xsd:boolean"/>
     <xsd:element name="queryLocator" type="xsd:string" nillable="true"/>
     <xsd:element name="records" minOccurs="0" maxOccurs="unbounded" type="tns:sObject" nillable="true"/>
     <xsd:element name="size" type="xsd:int"/>
    </xsd:sequence>
   </xsd:complexType>
   <xsd:complexType name="sObject">
    <xsd:sequence>
     <xsd:element name="fieldsToNull" minOccurs="0" maxOccurs="unbounded" type="xsd:string" nillable="true"/>
     <xsd:element name="Id" type="tns:ID" nillable="true"/>
    </xsd:sequence>
   </xsd:complexType>
   <xsd:complexType name="AJ__c">
    <xsd:complexContent>
     <xsd:extension base="tns:sObject">
      <xsd:sequence>
       <xsd:element name="AttachedContentDocuments" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="Attachments" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="CombinedAttachments" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="CreatedBy" minOccurs="0" type="tns:User" nillable="true"/>
       <xsd:element name="CreatedById" minOccurs="0" type="tns:ID" nillable="true"/>
       <xsd:element name="CreatedDate" minOccurs="0" type="xsd:dateTime" nillable="true"/>
       <xsd:element name="Email__c" minOccurs="0" type="xsd:string" nillable="true"/>
       <xsd:element name="FName__c" minOccurs="0" type="xsd:string" nillable="true"/>
       <xsd:element name="FeedSubscriptionsForEntity" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="Gender__c" minOccurs="0" type="xsd:string" nillable="true"/>
       <xsd:element name="IsDeleted" minOccurs="0" type="xsd:boolean" nillable="true"/>
       <xsd:element name="LastModifiedBy" minOccurs="0" type="tns:User" nillable="true"/>
       <xsd:element name="LastModifiedById" minOccurs="0" type="tns:ID" nillable="true"/>
       <xsd:element name="LastModifiedDate" minOccurs="0" type="xsd:dateTime" nillable="true"/>
       <xsd:element name="Name" minOccurs="0" type="xsd:string" nillable="true"/>
       <xsd:element name="Notes" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="NotesAndAttachments" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="Owner" minOccurs="0" type="tns:sObject" nillable="true"/>
       <xsd:element name="OwnerId" minOccurs="0" type="tns:ID" nillable="true"/>
       <xsd:element name="ProcessInstances" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="ProcessSteps" minOccurs="0" type="tns:QueryResult" nillable="true"/>
       <xsd:element name="SystemModstamp" minOccurs="0" type="xsd:dateTime" nillable="true"/>
      </xsd:sequence>
     </xsd:extension>
    </xsd:complexContent>
   </xsd:complexType>
   <xsd:element name="getAJRecords">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="fName" type="xsd:string" nillable="true"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:element name="getAJRecordsResponse">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="result" minOccurs="0" maxOccurs="unbounded" type="tns:AJ__c" nillable="true"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
  </xsd:schema>
 </types>

sushil77sushil77

part3:

 


 
 <!-- Message for the header parts -->
 <message name="Header">
  <part name="AllowFieldTruncationHeader" element="tns:AllowFieldTruncationHeader"/>
  <part name="CallOptions" element="tns:CallOptions"/>
  <part name="DebuggingHeader" element="tns:DebuggingHeader"/>
  <part name="DebuggingInfo" element="tns:DebuggingInfo"/>
  <part name="SessionHeader" element="tns:SessionHeader"/>
 </message>
 <!-- Operation Messages -->
 <message name="getAJRecordsRequest">
  <part element="tns:getAJRecords" name="parameters"/>
 </message>
 <message name="getAJRecordsResponse">
  <part element="tns:getAJRecordsResponse" name="parameters"/>
 </message>
 <portType name="CTSWebServicePortType">
  <operation name="getAJRecords">
   <input message="tns:getAJRecordsRequest"/>
   <output message="tns:getAJRecordsResponse"/>
  </operation>
 </portType>
 <binding name="CTSWebServiceBinding" type="tns:CTSWebServicePortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="getAJRecords">
   <soap:operation soapAction=""/>
   <input>
    <soap:header use="literal" part="SessionHeader" message="tns:Header"/>
    <soap:header use="literal" part="CallOptions" message="tns:Header"/>
    <soap:header use="literal" part="DebuggingHeader" message="tns:Header"/>
    <soap:header use="literal" part="AllowFieldTruncationHeader" message="tns:Header"/>
    <soap:body use="literal" parts="parameters"/>
   </input>
   <output>
    <soap:header use="literal" part="DebuggingInfo" message="tns:Header"/>
    <soap:body use="literal"/>
   </output>
  </operation>
 </binding>
 <service name="CTSWebServiceService">
  <documentation/>
  <port binding="tns:CTSWebServiceBinding" name="CTSWebService">
   <soap:address location="https://ap1.salesforce.com/services/Soap/class/CTSWebService"/>
  </port>
 </service>
</definitions>

bvramkumarbvramkumar

"Generate from WSDL" Button does not work most of the time.

 

I suggest you use HTTPRequest method to call the webservice.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm

 

If you want to find out the structure of SOAP request, use SOAPUI tool. http://www.soapui.org/. Download your WSDL as an xml file to your machine and try to get it parsed by this tool. It can parse almost any WSDL. Then you can get the structure of SOAP Request. Once you get the structure, try to build the same in Apex.