Question: How can I access an SAP system through an RFC?
Answer: Do the following steps:
Option 1
- Remote enable your function module and publish the web service generated for the RFC
- To understand the SOAP (XML) communication and to get some sample request data for the web service use the freeware soapUI
- Create a sample requests for a web service in soapUI with the WSDL that can be downloaded in soamanager in the NW system. Then you know what xml data is sent to the ERP system and how the response looks like.
- To generate and parse the same, there are a couple of options:
- JSON works fine
- or write your own generator
- In Objective-C you can also simply parse the xml data with NSXMLParser Object (only for parsing, without that CDATA stuff).
In order to bring those web services into the Apple services library, check out the following links:
- http://code.google.com/p/wsdl2objc/
- http://csoap.sourceforge.net/
- http://stackoverflow.com/questions/204465/how-to-access-soap-services-from-iphone
Notes:
- The JCO (java connector) provided by SAP has currently no ObjectiveC implementation
Option 2
What I did to consume an ABAP WebService from an iPhone app is: just create the ABAP WebService, configure the reverse proxy URL in SOAMANAGER, copy the URL, paste it to SOAP UI, generate an example WebService call, copy the generated XML and create an NSMutableString and paste the XML into it and then send an NSMutableURLRequest to the WebService. This works pretty fine and easy in ECC 6.0 and I do not have any trouble using the WSDLs. Of course you have to adjust your coding every time the WSDL changes. But in this case you have to do some other adjustments in your XCode coding anyways.
Plese find an example below:
[sRequest appendString:@"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:sap-com:document:sap:rfc:functions'>"]; [sRequest appendString:@"<soapenv:Header/><soapenv:Body><urn:Z_SK_SYNONYM_SEARCH><IV_SEARCH_STRING>TCO</IV_SEARCH_STRING></urn:Z_SK_SYNONYM_SEARCH></soapenv:Body></soapenv:Envelope>"]; NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://<<AS Server URL>>/rfc/sap/zsk_synonym_search/099/zsk_synonym_search/zsk_synonym_search"]]; [theRequest addValue:@"text/xml; charset:UTF-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue:@"Z_WS_TEST" forHTTPHeaderField:@"SOAPAction"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody:[sRequest dataUsingEncoding:NSUTF8StringEncoding]];
There is also a JSONParser in objective C that is available in Code Exchange:
https://cw.sdn.sap.com/cw/groups/objective-c-json-parser
It's still in its early days but is functional. Some clean and performance enhancements are needed, that's all work in progress. They are also looking at a JSON generator, but so far the services they are hitting take HTTP Post params and return JSON, so it is not a high priority for them.
If anyone is interested in helping please join the group.
Comments (2)
May 19, 2011
John Jakabcsin says:
Mario, Can you clarify what you mean by this - "configure the reverse proxy URL...Mario,
Can you clarify what you mean by this - "configure the reverse proxy URL in SOAMANAGER"?
Jul 09, 2012
Felix Baumann says:
Hi Mario, can you please explain, whats behind the Value Z_WS_TEST? regards F...Hi Mario,
can you please explain, whats behind the Value Z_WS_TEST?
regards
Felix