cancel
Showing results for 
Search instead for 
Did you mean: 

Consuming a function-module-based Web Service in an Interactive Form

martin_lass
Explorer
0 Kudos

Hello,

based on a simple SAP function module Z_EIN_WSTEST (importing I_TEST and exporting E_TEST, both of type CHAR40) I created a Web Service (with Web Service Definition Z_EIN_WSTEST_WS), which I can successfully invoke using SOAP Sonar. Since the SAP Web Service requires at least basic authentication I have to type in user name and password.

My task is now to invoke this web service in an SAP Interactive Form by Adobe. The Designer (I use Designer 8 as SAPGUI-addon with a NetWeaver 2004s server) provides a very comfortable way to consume Web Services by creating a WSDL-based data connection. That is very fine and easy but I had to learn that this approach does not support any authentication level.

What I learned further is that a Web Service that requires authentication can be invoked by using JavaScript only. Here is where my problems start: I am neither a Web Service nor a JavaScript expert. Does anyone know how to implement such a function?

This is my approach, which is not working yet, for a formula behind a standard button:

var url = "http://mydomain.com:8000/sap/bc/srt/rfc/sap/Z_EIN_WSTEST_WS?sap-client=100";

var request = { 
	"urn:sap-com:document:sap:rfc:functions:ZEININFWSTEST" : {ITest: "This is a test."}
};
var authentication = { 
	Username: "myUser",
	Password: "myPassword"
};

var response = SOAP.request ({
	cURL: url,
	oRequest: request,
	oAuthenticate: authentication
});

Accepted Solutions (1)

Accepted Solutions (1)

martin_lass
Explorer
0 Kudos

Hi,

thank you your help.

@Srikanth KV:

As far as I can see the Widgets' context for JavaScript is quite different from that of an Acrobat form. Nevertheless: Thank you for your hint.

@Anto J I

Lisha's blog entry is very useful, and I will keep it in mind (i.e. set a bookmark). But her method seems to have one drawback: It requires manual authentication with the web service.

For an automatic authentication is, as far as I know, the use of SOAP.request inevitable since only this method accepts an authentication parameter (user name and passwort).

Former Member
0 Kudos

Hi Martin,

If you require the user to log -in, you can go by the blog.

If you want a automatic log-in, you can set the default user-id and password in the web service configuration area. In that case, yopu wont require any scripting other than Dataconnection.execute.

As far as i understand, i wont recommend for a web service invocation from offline forms other than through Guided procedures and this is what i understand from SAP too.. due to security reasons.

Hope I answered your query.

Thnanks and regards,

Anto.

Answers (2)

Answers (2)

martin_lass
Explorer
0 Kudos

Hi Anto,

thank you for your hint: I do not know how to set a default user id and password in the web service configuration area (what transaction do you mean - WSCONFIG?) but somehow I must have manged to do it: I am not promped for login data any more when invoking my web service according to Lisha's blog.

Using Guided Procedure would be fine but, tell me if I am wrong, they can be used in an SAP portal context only.

Regards,

Martin

Former Member
0 Kudos

Hi,

as far as i know, yes it is.

Thanks and Regards,

Antony John Isacc.

former_member365727
Active Contributor
0 Kudos

Hi Martin,

I found this tutorial in Widgets gallery, using javascript to connect to R/3.

[Widget to connect R/3|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0cc5afe-9836-2a10-e484-88a7df046e99]

Also refer to this guide [Hello world widget with JCo Abstraction|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0ce3c19-6e34-2a10-a38e-8a8481cd13d1]

These widgets are written in java script to connect R/3, hope this solves your problem.

Regards

Srikanth KV.

Former Member
0 Kudos

Hey check out this blog. -> Link: [https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/7588] [original link is broken] [original link is broken] [original link is broken];

Hope this would help you.

- anto.