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

how to connect SAP wsdl with Salesforce

Hi All,

        I having SAP WSDL file how to connect this wsdl file with Salesforce.


        After connecting this WSDL file with salesforce, using this I want only to view the data. kindly anyone tell how to resolve this.




user generate APEX from WSDL
so you can convert this WSDL file into apex classes

Thanks for reply,i am getting this error when generate apex classes.

Apex Generation Failed Unsupported schema type: {}anyType



These are the code lines that are creating errors:



<element name="NewValue" nillable="true" minOccurs="0" type="xsd:anyType"/>
<element name="OldValue" nillable="true" minOccurs="0" type="xsd:anyType"/>

 I changed "anytype" to "string" and then i was able to generate apex classes from enterprise wsdls.


Please mark this as resolved if it is resolved ,It will help others.





Now i am getting this Error:

Apex Generation FailedUnable to find soap 1.1 address
Salesforce support only soap 1.1 but SAP wsdl generate soap 1.2. How to convert sap soap 1.2 to soap 1.1. 

I have created the apex class after generated from WSDl. Now i need to do "Invoking an external server". I am new this, how to do this invoking. Kindly tell the link about this .



You will have to identify function from the class and then u have to use that in your class.


For example if function name is lookup


 You have to create an object of the apex class in your class and then call that function which is there in  apex  generated class  and pass parameters to that 


Classs p


 dial d=new dial;


d.lookup()   //pass parameters to it and then it will return web service.You will do this if u are calling sopa based web services .if not then you will use reste based servccies.In which you create Http objects and send data to the Endpoint URL.



How did u resolve version error 





Reponse to SOAP 1.1:

In our generated WSDL file we will get 2 WSDL:Binding and 2 WSDL: port.  Goto the text editor of the
WSDl file ,Comment the 2nd WSDL:Binding and also comment the 2nd WSDL:port. Then save it. It will save it in version 1.1.


My issue:


          To create a Apex class and Trigger for this generated WSDL file to get the data from SAP SD system,that is in Salesforce if i give the account number it must get the related data of that record.

Example :In salesforce if i give the Account No : ZZZZZZ means, it must fetch the account  ZZZZZZ data from SAP SD system and display it in salesforce.

Kindly tell how to create a Apex class and Trigger for this.


Generated WSDL 2 Apex Code:


//Generated by wsdl2apex

public class sapComDocumentSapSoapFunctionsMcS {
public class zsd_cust_det_webservice {
public String endpoint_x = 'http://serverapp5.cssydney.local:8000/sap/bc/srt/rfc/sap/zsd_cust_det_webservice/100/zsd_cust_det_webservice/zsd_cust_det_webservice';
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:soap:functions:mc-style', 'sapComDocumentSapSoapFunctionsMcS', 'urn:sap-com:document:sap:rfc:functions', 'sapComDocumentSapRfcFunctions'};
public sapComDocumentSapSoapFunctionsMcS.ZsdTCustDet ZsdCustWebservDemo(String IvAcctNo) {
sapComDocumentSapSoapFunctionsMcS.ZsdCustWebservDemo_element request_x = new sapComDocumentSapSoapFunctionsMcS.ZsdCustWebservDemo_element();
sapComDocumentSapSoapFunctionsMcS.ZsdCustWebservDemoResponse_element response_x;
request_x.IvAcctNo = IvAcctNo;
Map<String, sapComDocumentSapSoapFunctionsMcS.ZsdCustWebservDemoResponse_element> response_map_x = new Map<String, sapComDocumentSapSoapFunctionsMcS.ZsdCustWebservDemoResponse_element>();
response_map_x.put('response_x', response_x);
new String[]{endpoint_x,
response_x = response_map_x.get('response_x');
return response_x.EtAccDet;
public class ZsdCustWebservDemo_element {
public String IvAcctNo;
private String[] IvAcctNo_type_info = new String[]{'IvAcctNo','urn:sap-com:document:sap:rfc:functions','char10','1','1','false'};
private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:soap:functions:mc-style','false','true'};
private String[] field_order_type_info = new String[]{'IvAcctNo'};
public class ZsdSCustDet {
public String AcctNo;
public String SalesOrdNo;
public String PoNo;
public String PoDate;
public String NetVal;
public String Currency_x;
private String[] AcctNo_type_info = new String[]{'AcctNo','urn:sap-com:document:sap:rfc:functions','char10','1','1','false'};
private String[] SalesOrdNo_type_info = new String[]{'SalesOrdNo','urn:sap-com:document:sap:rfc:functions','char10','1','1','false'};
private String[] PoNo_type_info = new String[]{'PoNo','urn:sap-com:document:sap:rfc:functions','char20','1','1','false'};
private String[] PoDate_type_info = new String[]{'PoDate','urn:sap-com:document:sap:rfc:functions','date','1','1','false'};
private String[] NetVal_type_info = new String[]{'NetVal','urn:sap-com:document:sap:rfc:functions','curr15.2','1','1','false'};
private String[] Currency_x_type_info = new String[]{'Currency','urn:sap-com:document:sap:rfc:functions','cuky5','1','1','false'};
private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:soap:functions:mc-style','false','true'};
private String[] field_order_type_info = new String[]{'AcctNo','SalesOrdNo','PoNo','PoDate','NetVal','Currency_x'};
public class ZsdTCustDet {
public sapComDocumentSapSoapFunctionsMcS.ZsdSCustDet[] item;
private String[] item_type_info = new String[]{'item','urn:sap-com:document:sap:soap:functions:mc-style','ZsdSCustDet','0','-1','false'};
private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:soap:functions:mc-style','false','true'};
private String[] field_order_type_info = new String[]{'item'};
public class ZsdCustWebservDemoResponse_element {
public sapComDocumentSapSoapFunctionsMcS.ZsdTCustDet EtAccDet;
private String[] EtAccDet_type_info = new String[]{'EtAccDet','urn:sap-com:document:sap:soap:functions:mc-style','ZsdTCustDet','1','1','false'};
private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:soap:functions:mc-style','false','true'};
private String[] field_order_type_info = new String[]{'EtAccDet'};







Hi ,

Trigger  Try on account(after insert)


set<account>ids=new set<account>();







public class test


public static check(set<account> i)



list<account>lic=[select accountnumber from account where id in: i];

for( account s:lic)


//call your webservice method and pass account numbers to it

sapComDocumentSapSoapFunctionsMcS create=new sapComDocumentSapSoapFunctionsMcS(); //took this class from you apex generated class and sapwebservicemethod(just a fake method which I created,you need to ask your sap team which method you need).

create. sapwebservicemethod(s.accountnumber);




The above given steps are just to explain you how you can use triggers and class to call webservice method.There are other things which u should consider such as @future method etc.for aynschronous processing.


Personally I do not think that you are using Soap based webservicues.It looks like you will be using rest based wervices.First be sure about that.



Hi surprise,

 This my @future method:


global class WebServiceCallout123 {

public WebServiceCallout123(ApexPages.StandardController controller) {


@future (callout=true)
WebService static void sendNotification() {

// //Set your username and password here
// public string get_sap_data;
String username = 'xxxxxx';
String password = 'yyyyyy';
// //Construct HTTP request and response
System.HttpRequest req = new HttpRequest();
System.HttpResponse res = new HttpResponse();
System.Http http = new Http();
// //Construct Authorization and Content header
Blob headerValue = Blob.valueOf(username+':'+password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
// //Set Method and Endpoint and Body

//System.debug('SalesOrdNo -->' + SalesOrdNo);
//req.getParameters()=['Select a.PoNo From kanl where ZsdSCustDet=@id' ];
// get_sap_data=[select id ,PoNo_x from SalesOrdNo_x where id= 'SAP_SD__c'];
try {
//Send endpoint to JIRA
res = http.send(req);
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.INFO,'Salesforce connecting'));

} catch(System.CalloutException e) {
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.INFO,'Salesforce error'));

public static testMethod void testMe() {



im new in apex code thats why asking silly question.


I create SAP_no custom field in SAP custom object ,enter the customer number[000010005] in that field ,salesforce connect the sap to reterive the relavant data of that number[000010005] in salesforce.


how to reterive sap records like('SalesOrdNo','PoNo','PoDate','NetVal','Currency_x') in apex class code.pls dont ignore it.


Your scenario is not clear.First,what are u trying to pass from salesforce ?Are you passing some number from salesforce to sap and in response you are expecting some thing to come back to u and you want to know how to fetch resposne in salesforce .If that is the case then you have to use getbody() method to pull out the values from the returned response.


res = http.send(req);


res.getbody() will get you the response from the sap .


Try to use system.debug(res.getbody()) to see what response you get from the sap service.






any one integrate salesforce with sap plz share your codes im new in salesforce 

Roopa SarathkumarRoopa Sarathkumar

Did you manage to do this?

I am trying to do the same thing, can u tell me how you solved this?
Is there any other way to integrate salesforce with sap