Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

System-independent (and transportable) web service

Hello,

I would like to use a web service in my Interactive Form. Therefore, I created an RFC function module and created the corresponding web service. Then I launched SOAMANAGER to get the URL of the WSDL file, copy it, changed it a bit (removed the last part: "?sap-client=100", otherwise Adobe LiveCycle Designer would not accept it) and pasted into the "New Data Connection" dialog box in ALCD.

But this URL is system-dependent (begin with the development system hostname). So, once transported to other systems (integration, quality or production), it won't work anymore.

So, my first question is: how to make it system-independent?

My second question is: how to transport web services?

Thanks in advance.

Mathieu

Former Member
Former Member replied

Hi,

Sorry for the late reply. It was tricky, but I finally found out how to make it system independant. It was really tricky to make it work fine, so here is the solution:

1) The Web Service URL will have to be an entry parameter of the Interactive PDF. You can generate it this way:

  CONSTANTS: lc_http_protocol_id  TYPE icmproto VALUE 1,
             lc_web_service_name  TYPE string   VALUE 'my_web_service_name',
             lc_http              TYPE string   VALUE 'http://',
             lc_web_service_dir   TYPE string   VALUE 'sap/bc/srt/rfc/sap',
             lc_sep               TYPE c        VALUE '/'.

    CALL FUNCTION 'ICM_GET_INFO'
      TABLES
        servlist = lt_server_info.

    LOOP AT lt_server_info  INTO ls_server_info
                            WHERE active = abap_true
                            AND protocol = lc_http_protocol_id.
*                            AND hostname CS sy-host.
    ENDLOOP.

    IF sy-subrc EQ 0.

      CONCATENATE lc_http ls_server_info-hostname ':' ls_server_info-service INTO lv_web_service_url.
      CONCATENATE lv_web_service_url
                  lc_web_service_dir
                  lc_web_service_name
                  sy-mandt
                  lc_web_service_name
                  lc_web_service_name
                  INTO lv_web_service_url
                  SEPARATED BY lc_sep.

2) In the Interactive Form, use the following javascript code:

try {
	var urlObject = xfa.record.WEB_SERVICE_URL;
	var url = urlObject.value;
	
	var request = {};
	request["urn:sap-com:document:sap:soap:functions:mc-style:MyWebServiceMethod"] = {myParameter: 'My parameter value'};	

	var response = SOAP.request({
		cURL: url,
		oRequest: request,
		cNamespace: "urn:sap-com:document:sap:soap:functions:mc-style"
	});
	
// get the response values
	xfa.record.MyValue.value = response["urn:sap-com:document:sap:soap:functions:mc-style:MyWebServiceMethod"]["MyResponseParameter"];

} catch (e) {
	xfa.host.messageBox(e.toString());
}

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question