Skip to Content

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

invoking a web service

Hello All,

I am trying to invoke a web service hosted on webMethods (our R/3 being an older version, can't expose function modules as web services). I am able to generate Java proxies from the wsdl provided by webMethods. But, I found by studying the generated Java proxies/stubs that its required to send both input (import) and output (export) parameters to invoke the function module.

To give you an example, lets say, my function module takes 3 input parameters and returns 120 output parameters. So, to invoke this function, I thought I just need 3 parameters to be supplied to make a call like invokeXYZ(param1, param2, param3). But, when I looked at the generated code, I saw that I need to supply a total of 3 + 120 parameters to invoke the web service. 120 of them are empty objects of type output parameter.

I think either SAP isn't generating the proxy classes correctly (You don't want to supply 120 arguments to make a call) or I am doing something wrong.

Any suggestions/comments appreciated.





This very unusual WSDL, however it is valid. And SAP plugins generate correct proxy classes.

So you have 3 IN parameters, and 120 IN-OUT parameters. You have to assign <b>new StringHolder</b> to all of these 120 parameters (otherwise you got NullPointerException on execute).

Here is the short way (shorter then 120 assignments

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.InvocationTargetException;
final Method[] methods =

final Object[] args = {null};
  for (int i = 0, c = methods.length; i < c; i++)
    final Method m = methods[ i ];
    if ( !m.getName().startsWith("set") ) continue;

    final int flags = m.getModifiers();
    if ( !Modifier.isPublic(flags) || Modifier.isStatic(flags) ) continue;
    final Class[] types = m.getParameterTypes();
    if ( null == types || types.length != 1 || types[0] != StringHolder.class ) continue;
    /* Now we now that this is method that assigns IN_OUT parameter */
    /* "request" below is your WebService request instance, type Request_.... */
    args[0] = new StringHolder();
    m.invoke( request, args );
catch (final IllegalAccessException ex) { throw new RuntimeException(ex); }		
catch (final IllegalArgumentException ex) { throw new RuntimeException(ex); }		
catch (final InvocationTargetException ex) { throw new RuntimeException(ex.getTargetException()); }

Valery Silaev

EPAM Systems

Message was edited by: Valery Silaev

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question