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
jayalajayala 

Callouts problem

I am getting the following error when i tried to make a callout to SAP webservice.

 

I have registered my endpoint in sfdc. I amusing WSDL1.1 for my wsdl to create WSDL2Apex.

 

System.LimitException: @future call currently not allowed 

 

Any help is appreciated.

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

jayalajayala

 

>Thanks for the first response... i am still having problem.

Following is my wsdl

  <?xml version="1.0" encoding="UTF-8" ?>
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:s0="urn:sap-com:document:sap:rfc:functions" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="urn:sap-com:document:sap:rfc:functions">
- <types>
- <xsd:schema targetNamespace="urn:sap-com:document:sap:rfc:functions">
- <xsd:element name="BAPI_CUSTOMER_DISPLAY">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="CUSTOMERNO">
+ <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="10" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
- <xsd:element name="BAPI_CUSTOMER_DISPLAY.Response">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element name="RETURN" type="s0:BAPIRET1" />
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
- <xsd:complexType name="BAPIRET1">
- <xsd:sequence>
- <xsd:element name="TYPE" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="1" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="ID" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="20" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="NUMBER" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="3" />
  <xsd:pattern value="\d*" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESSAGE" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="220" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="LOG_NO" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="20" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="LOG_MSG_NO" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="6" />
  <xsd:pattern value="\d*" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESSAGE_V1" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="50" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESSAGE_V2" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="50" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESSAGE_V3" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="50" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESSAGE_V4" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:length value="50" />
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
  </xsd:schema>
  </types>
- <message name="BAPI_CUSTOMER_DISPLAYInput">
  <part name="parameters" element="s0:BAPI_CUSTOMER_DISPLAY" />
  </message>
+ <message name="BAPI_CUSTOMER_DISPLAYOutput">
  <part name="parameters" element="s0:BAPI_CUSTOMER_DISPLAY.Response" />
  </message>
- <portType name="BAPI_CUSTOMER_DISPLAYPortType">
- <operation name="BAPI_CUSTOMER_DISPLAY">
  <input message="s0:BAPI_CUSTOMER_DISPLAYInput" />
  <output message="s0:BAPI_CUSTOMER_DISPLAYOutput" />
  </operation>
  </portType>
- <binding name="BAPI_CUSTOMER_DISPLAYBinding" type="s0:BAPI_CUSTOMER_DISPLAYPortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="BAPI_CUSTOMER_DISPLAY">
  <soap:operation soapAction="http://www.sap.com/BAPI_CUSTOMER_DISPLAY" />
- <input>
  <soap:body use="literal" />
  </input>
- <output>
  <soap:body use="literal" />
  </output>
  </operation>
  </binding>
- <service name="BAPI_CUSTOMER_DISPLAYService">
  <documentation>SAP Service BAPI_CUSTOMER_DISPLAY via SOAP</documentation>
- <port name="BAPI_CUSTOMER_DISPLAYPortType" binding="s0:BAPI_CUSTOMER_DISPLAYBinding">
  <soap:address location="http://**.**.**.***:8000/sap/bc/soap/rfc" />
  </port>
  </service>
  </definitions>

 

Following is the Wsdl2Apex from salesforce

//Generated by wsdl2apex

public class sapComDocumentSapRfcFunctions {
    public class ZCUSTOMER_HELP_Response_element {
        public String E_CUSTOMER;
        public String E_NAME;
        private String[] E_CUSTOMER_type_info = new String[]{'E_CUSTOMER','urn:sap-com:document:sap:rfc:functions','E_CUSTOMER_element','1','1','false'};
        private String[] E_NAME_type_info = new String[]{'E_NAME','urn:sap-com:document:sap:rfc:functions','E_NAME_element','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'E_CUSTOMER','E_NAME'};
    }
    public class ZCUSTOMER_HELPPortType {
        public String endpoint_x = 'http://**.**.**.***:8000/sap/bc/soap/rfc';
        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;
        private String[] ns_map_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions', 'sapComDocumentSapRfcFunctions'};
        public sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_Response_element ZCUSTOMER_HELP(Integer I_COUNT,String I_CUSTOMER) {
            sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_element request_x = new sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_element();
            sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_Response_element response_x;
            request_x.I_COUNT = I_COUNT;
            request_x.I_CUSTOMER = I_CUSTOMER;
            Map<String, sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_Response_element> response_map_x = new Map<String, sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_Response_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.sap.com/ZCUSTOMER_HELP',
              'urn:sap-com:document:sap:rfc:functions',
              'ZCUSTOMER_HELP',
              'urn:sap-com:document:sap:rfc:functions',
              'ZCUSTOMER_HELP.Response',
              'sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_Response_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
    public class ZCUSTOMER_HELP_element {
        public Integer I_COUNT;
        public String I_CUSTOMER;
        private String[] I_COUNT_type_info = new String[]{'I_COUNT','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] I_CUSTOMER_type_info = new String[]{'I_CUSTOMER','urn:sap-com:document:sap:rfc:functions','I_CUSTOMER_element','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'I_COUNT','I_CUSTOMER'};
    }
 }

 

My client call is

 System.debug(' callservice begin -- ');
    sapComDocumentSapRfcFunctions.ZCUSTOMER_HELPPortType stub  = new sapComDocumentSapRfcFunctions.ZCUSTOMER_HELPPortType();
    sapComDocumentSapRfcFunctions.ZCUSTOMER_HELP_Response_element result = stub.ZCUSTOMER_HELP(1,'jay');
    //String result  = stub.ZCUSTOMER_HELP(1);
    System.debug('result ---'+result);

 

Following is the error i am getting

 

11:16:14:220 CALLOUT_RESPONSE [28]|This service requires client certificate for authentication procedure.

 

Qtn1 ) From WSDL i can see only 1 input parameter for request for the method ZCUSTOMER_HELP. But if i see Apex code it takes 2 parameters .Please let me know if i amlooking this wrongly. 

Qtn 2) I am making just a http call. Do i need to setup any credentials for this like user name and password..? how can iset them .

 

Help is appreciated.