-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
1Questions
-
1Replies
while calling a apex class generated by wsdl2apex, through anonymous block getting error 'System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID'
Below is the apex class for which I have generated a wsdl
global class DemoWS{
static webservice String greetings(){
String s='Happy Holidays';
return s;
}
}
Below is my wsdl which I have used in another org to generate apex class---
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!-- Web Services API : custom_package.DemoWS -->
<definitions 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/custom_package/DemoWS" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<xsd:element name="AllowFieldTruncationHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="allowFieldTruncation" type="xsd:boolean"/>
</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="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: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="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: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>
<xsd:element name="DebuggingInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="debugLog" 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: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:element name="greetings">
<xsd:complexType>
<xsd:sequence/>
</xsd:complexType>
</xsd:element>
<xsd:element name="greetingsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<!-- 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="greetingsRequest">
<part element="tns:greetings" name="parameters"/>
</message>
<message name="greetingsResponse">
<part element="tns:greetingsResponse" name="parameters"/>
</message>
<portType name="DemoWSPortType">
<operation name="greetings">
<input message="tns:greetingsRequest"/>
<output message="tns:greetingsResponse"/>
</operation>
</portType>
<binding name="DemoWSBinding" type="tns:DemoWSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="greetings">
<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="DemoWSService">
<documentation/>
<port binding="tns:DemoWSBinding" name="DemoWS">
<soap:address location="https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS"/>
</port>
</service>
</definitions>
Using the above wsdl the generated apex is below
//Generated by wsdl2apex
public class demo {
public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};
}
public class AllowFieldTruncationHeader_element {
public Boolean allowFieldTruncation;
private String[] allowFieldTruncation_type_info = new String[]{'allowFieldTruncation','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'allowFieldTruncation'};
}
public class DebuggingHeader_element {
public demo.LogInfo[] categories;
public String debugLevel;
private String[] categories_type_info = new String[]{'categories','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'0','-1','false'};
private String[] debugLevel_type_info = new String[]{'debugLevel','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'categories','debugLevel'};
}
public class CallOptions_element {
public String client;
private String[] client_type_info = new String[]{'client','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'client'};
}
public class greetingsResponse_element {
public String result;
private String[] result_type_info = new String[]{'result','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','true'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'result'};
}
public class SessionHeader_element {
public String sessionId;
private String[] sessionId_type_info = new String[]{'sessionId','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'sessionId'};
}
public class DebuggingInfo_element {
public String debugLog;
private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'debugLog'};
}
public class greetings_element {
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class DemoWS {
public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
public demo.SessionHeader_element SessionHeader;
public demo.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
public demo.DebuggingHeader_element DebuggingHeader;
public demo.DebuggingInfo_element DebuggingInfo;
public demo.CallOptions_element CallOptions;
private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS', 'demo'};
public String greetings() {
demo.greetings_element request_x = new demo.greetings_element();
demo.greetingsResponse_element response_x;
Map<String, demo.greetingsResponse_element> response_map_x = new Map<String, demo.greetingsResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetings',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetingsResponse',
'demo.greetingsResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.result;
}
}
}
and the anonymous block where I have used the below code to run that apex is
demo.DemoWS stub = new demo.DemoWS();
stub.greetings();
I have used correct endpoint in remote settings .
Please help .
Thanks in advance.
global class DemoWS{
static webservice String greetings(){
String s='Happy Holidays';
return s;
}
}
Below is my wsdl which I have used in another org to generate apex class---
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!-- Web Services API : custom_package.DemoWS -->
<definitions 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/custom_package/DemoWS" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<xsd:element name="AllowFieldTruncationHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="allowFieldTruncation" type="xsd:boolean"/>
</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="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: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="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: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>
<xsd:element name="DebuggingInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="debugLog" 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: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:element name="greetings">
<xsd:complexType>
<xsd:sequence/>
</xsd:complexType>
</xsd:element>
<xsd:element name="greetingsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<!-- 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="greetingsRequest">
<part element="tns:greetings" name="parameters"/>
</message>
<message name="greetingsResponse">
<part element="tns:greetingsResponse" name="parameters"/>
</message>
<portType name="DemoWSPortType">
<operation name="greetings">
<input message="tns:greetingsRequest"/>
<output message="tns:greetingsResponse"/>
</operation>
</portType>
<binding name="DemoWSBinding" type="tns:DemoWSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="greetings">
<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="DemoWSService">
<documentation/>
<port binding="tns:DemoWSBinding" name="DemoWS">
<soap:address location="https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS"/>
</port>
</service>
</definitions>
Using the above wsdl the generated apex is below
//Generated by wsdl2apex
public class demo {
public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};
}
public class AllowFieldTruncationHeader_element {
public Boolean allowFieldTruncation;
private String[] allowFieldTruncation_type_info = new String[]{'allowFieldTruncation','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'allowFieldTruncation'};
}
public class DebuggingHeader_element {
public demo.LogInfo[] categories;
public String debugLevel;
private String[] categories_type_info = new String[]{'categories','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'0','-1','false'};
private String[] debugLevel_type_info = new String[]{'debugLevel','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'categories','debugLevel'};
}
public class CallOptions_element {
public String client;
private String[] client_type_info = new String[]{'client','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'client'};
}
public class greetingsResponse_element {
public String result;
private String[] result_type_info = new String[]{'result','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','true'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'result'};
}
public class SessionHeader_element {
public String sessionId;
private String[] sessionId_type_info = new String[]{'sessionId','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'sessionId'};
}
public class DebuggingInfo_element {
public String debugLog;
private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'debugLog'};
}
public class greetings_element {
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class DemoWS {
public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
public demo.SessionHeader_element SessionHeader;
public demo.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
public demo.DebuggingHeader_element DebuggingHeader;
public demo.DebuggingInfo_element DebuggingInfo;
public demo.CallOptions_element CallOptions;
private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS', 'demo'};
public String greetings() {
demo.greetings_element request_x = new demo.greetings_element();
demo.greetingsResponse_element response_x;
Map<String, demo.greetingsResponse_element> response_map_x = new Map<String, demo.greetingsResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetings',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetingsResponse',
'demo.greetingsResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.result;
}
}
}
and the anonymous block where I have used the below code to run that apex is
demo.DemoWS stub = new demo.DemoWS();
stub.greetings();
I have used correct endpoint in remote settings .
Please help .
Thanks in advance.
- Anu Roy
- December 05, 2014
- Like
- 0
while calling a apex class generated by wsdl2apex, through anonymous block getting error 'System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID'
Below is the apex class for which I have generated a wsdl
global class DemoWS{
static webservice String greetings(){
String s='Happy Holidays';
return s;
}
}
Below is my wsdl which I have used in another org to generate apex class---
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!-- Web Services API : custom_package.DemoWS -->
<definitions 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/custom_package/DemoWS" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<xsd:element name="AllowFieldTruncationHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="allowFieldTruncation" type="xsd:boolean"/>
</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="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: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="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: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>
<xsd:element name="DebuggingInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="debugLog" 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: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:element name="greetings">
<xsd:complexType>
<xsd:sequence/>
</xsd:complexType>
</xsd:element>
<xsd:element name="greetingsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<!-- 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="greetingsRequest">
<part element="tns:greetings" name="parameters"/>
</message>
<message name="greetingsResponse">
<part element="tns:greetingsResponse" name="parameters"/>
</message>
<portType name="DemoWSPortType">
<operation name="greetings">
<input message="tns:greetingsRequest"/>
<output message="tns:greetingsResponse"/>
</operation>
</portType>
<binding name="DemoWSBinding" type="tns:DemoWSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="greetings">
<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="DemoWSService">
<documentation/>
<port binding="tns:DemoWSBinding" name="DemoWS">
<soap:address location="https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS"/>
</port>
</service>
</definitions>
Using the above wsdl the generated apex is below
//Generated by wsdl2apex
public class demo {
public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};
}
public class AllowFieldTruncationHeader_element {
public Boolean allowFieldTruncation;
private String[] allowFieldTruncation_type_info = new String[]{'allowFieldTruncation','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'allowFieldTruncation'};
}
public class DebuggingHeader_element {
public demo.LogInfo[] categories;
public String debugLevel;
private String[] categories_type_info = new String[]{'categories','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'0','-1','false'};
private String[] debugLevel_type_info = new String[]{'debugLevel','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'categories','debugLevel'};
}
public class CallOptions_element {
public String client;
private String[] client_type_info = new String[]{'client','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'client'};
}
public class greetingsResponse_element {
public String result;
private String[] result_type_info = new String[]{'result','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','true'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'result'};
}
public class SessionHeader_element {
public String sessionId;
private String[] sessionId_type_info = new String[]{'sessionId','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'sessionId'};
}
public class DebuggingInfo_element {
public String debugLog;
private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'debugLog'};
}
public class greetings_element {
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class DemoWS {
public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
public demo.SessionHeader_element SessionHeader;
public demo.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
public demo.DebuggingHeader_element DebuggingHeader;
public demo.DebuggingInfo_element DebuggingInfo;
public demo.CallOptions_element CallOptions;
private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS', 'demo'};
public String greetings() {
demo.greetings_element request_x = new demo.greetings_element();
demo.greetingsResponse_element response_x;
Map<String, demo.greetingsResponse_element> response_map_x = new Map<String, demo.greetingsResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetings',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetingsResponse',
'demo.greetingsResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.result;
}
}
}
and the anonymous block where I have used the below code to run that apex is
demo.DemoWS stub = new demo.DemoWS();
stub.greetings();
I have used correct endpoint in remote settings .
Please help .
Thanks in advance.
global class DemoWS{
static webservice String greetings(){
String s='Happy Holidays';
return s;
}
}
Below is my wsdl which I have used in another org to generate apex class---
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!-- Web Services API : custom_package.DemoWS -->
<definitions 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/custom_package/DemoWS" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/custom_package/DemoWS">
<xsd:element name="AllowFieldTruncationHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="allowFieldTruncation" type="xsd:boolean"/>
</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="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: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="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: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>
<xsd:element name="DebuggingInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="debugLog" 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: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:element name="greetings">
<xsd:complexType>
<xsd:sequence/>
</xsd:complexType>
</xsd:element>
<xsd:element name="greetingsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<!-- 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="greetingsRequest">
<part element="tns:greetings" name="parameters"/>
</message>
<message name="greetingsResponse">
<part element="tns:greetingsResponse" name="parameters"/>
</message>
<portType name="DemoWSPortType">
<operation name="greetings">
<input message="tns:greetingsRequest"/>
<output message="tns:greetingsResponse"/>
</operation>
</portType>
<binding name="DemoWSBinding" type="tns:DemoWSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="greetings">
<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="DemoWSService">
<documentation/>
<port binding="tns:DemoWSBinding" name="DemoWS">
<soap:address location="https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS"/>
</port>
</service>
</definitions>
Using the above wsdl the generated apex is below
//Generated by wsdl2apex
public class demo {
public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};
}
public class AllowFieldTruncationHeader_element {
public Boolean allowFieldTruncation;
private String[] allowFieldTruncation_type_info = new String[]{'allowFieldTruncation','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'allowFieldTruncation'};
}
public class DebuggingHeader_element {
public demo.LogInfo[] categories;
public String debugLevel;
private String[] categories_type_info = new String[]{'categories','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'0','-1','false'};
private String[] debugLevel_type_info = new String[]{'debugLevel','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'categories','debugLevel'};
}
public class CallOptions_element {
public String client;
private String[] client_type_info = new String[]{'client','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'client'};
}
public class greetingsResponse_element {
public String result;
private String[] result_type_info = new String[]{'result','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','true'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'result'};
}
public class SessionHeader_element {
public String sessionId;
private String[] sessionId_type_info = new String[]{'sessionId','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'sessionId'};
}
public class DebuggingInfo_element {
public String debugLog;
private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/custom_package/DemoWS',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{'debugLog'};
}
public class greetings_element {
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class DemoWS {
public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/custom_package/DemoWS';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
public demo.SessionHeader_element SessionHeader;
public demo.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
public demo.DebuggingHeader_element DebuggingHeader;
public demo.DebuggingInfo_element DebuggingInfo;
public demo.CallOptions_element CallOptions;
private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/custom_package/DemoWS';
private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/custom_package/DemoWS', 'demo'};
public String greetings() {
demo.greetings_element request_x = new demo.greetings_element();
demo.greetingsResponse_element response_x;
Map<String, demo.greetingsResponse_element> response_map_x = new Map<String, demo.greetingsResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetings',
'http://soap.sforce.com/schemas/class/custom_package/DemoWS',
'greetingsResponse',
'demo.greetingsResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.result;
}
}
}
and the anonymous block where I have used the below code to run that apex is
demo.DemoWS stub = new demo.DemoWS();
stub.greetings();
I have used correct endpoint in remote settings .
Please help .
Thanks in advance.
- Anu Roy
- December 05, 2014
- Like
- 0