users@jax-rpc.java.net

RE: Re: DII client: IndexOutOfBoundsException when calling method with 0 argument

From: Abhishek Agrawal <abhishek.agrawal_at_appiancorp.com>
Date: Mon, 11 Oct 2004 11:59:35 -0400

  public Object doCall(
    String wsdlURL_,
    String serviceName_,
    String operationName_,
    Object[] args_) {
    try {
      ServiceFactory factory = ServiceFactory.newInstance();
      WsdlParser wsParser = new WsdlParser(wsdlURL_);
      Service ser = wsParser.selectService(null, serviceName_);
      javax.xml.rpc.Service service =
        factory.createService(new URL(wsdlURL_), ser.getQName());
      Port port = wsParser.selectPort(ser.getPorts(), null);
      QName qPort = new QName(port.getName());
      Call call = service.createCall(qPort);
      List soapElement = ser.getPort(port.getName()).getExtensibilityElements();
      if (soapElement.size() > 0) {
        for (int i = 0; i < soapElement.size(); i++) {
          if (soapElement.get(i) instanceof SOAPAddress) {
            SOAPAddress sa = (SOAPAddress) soapElement.get(i);
            call.setTargetEndpointAddress(sa.getLocationURI());
            break;
          } else if (
            soapElement.get(i)
              instanceof com.sun.xml.rpc.wsdl.document.soap.SOAPAddress) {
            com.sun.xml.rpc.wsdl.document.soap.SOAPAddress sa =
              (com.sun.xml.rpc.wsdl.document.soap.SOAPAddress) soapElement.get(
                i);
            call.setTargetEndpointAddress((sa).getLocation());
            break;
          }
        }
      }
      BindingEntry be = getBindingEntry(wsParser.getWsdlParser(), port);
      BindingOperation operation = getBindingOperation(be, operationName_);
      List extElements = operation.getExtensibilityElements();
      if (extElements != null && extElements.size() > 0) {
        for (int i = 0; i < extElements.size(); i++) {
          if (extElements.get(i) instanceof SOAPOperation) {
            SOAPOperation sb = (SOAPOperation) extElements.get(i);
            if (sb.getRequired() != null)
              call.setProperty(Call.SOAPACTION_USE_PROPERTY, sb.getRequired());
            else
              call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
            if (sb.getStyle() != null)
              call.setProperty(Call.OPERATION_STYLE_PROPERTY, sb.getStyle());
            call.setProperty(
              Call.SOAPACTION_URI_PROPERTY,
              sb.getSoapActionURI());
            break;
          }
        }
      }

      boolean setEncoding = false;
      List soapBodyList =
        operation.getBindingInput().getExtensibilityElements();
      if (soapBodyList.size() > 0) {
        for (int i = 0; i < soapBodyList.size(); i++) {
          if (soapBodyList.get(i) instanceof SOAPBody) {
            SOAPBody sb = (SOAPBody) soapBodyList.get(i);
            List encodingStyle = sb.getEncodingStyles();
            if (encodingStyle != null && encodingStyle.size() > 0) {
              String encoStyle = (String) encodingStyle.get(0);
              call.setProperty(ENCODING_STYLE_PROPERTY, encoStyle);
              setEncoding = true;
              break;
            }
          }
        }
      }
      if (!setEncoding)
        call.setProperty(ENCODING_STYLE_PROPERTY, "");

      call.setOperationName(
        new QName(ser.getQName().getNamespaceURI(), operationName_));

      //Parameters parameters =
      // getParameters(operationName_,wsParser.getAxisParser(),port);
      Parameters parameters =
        (Parameters) be.getParameters().get(operation.getOperation());
      for (int j = 0; j < parameters.list.size(); ++j) {
        Parameter p = (Parameter) parameters.list.get(j);
        int mode = p.getMode();
        switch (mode) {
          case Parameter.IN :
            call.addParameter(
              p.getName(),
              p.getType().getQName(),
              ParameterMode.IN);
            break;
          case Parameter.OUT :
            call.addParameter(
              p.getName(),
              p.getType().getQName(),
              ParameterMode.OUT);
            break;
          case Parameter.INOUT :
            call.addParameter(
              p.getName(),
              p.getType().getQName(),
              ParameterMode.INOUT);
            break;
        }
      }
      if (parameters.returnParam != null) {
        QName returnType = org.apache.axis.wsdl.toJava.Utils.getXSIType(
            parameters.returnParam);
        QName returnQName = parameters.returnParam.getQName();

        call.setReturnType(returnQName);
      }
      Object result = call.invoke(args_);
      Map map = call.getOutputParams();
      System.out.println("returned " + result);

      return result;

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return null;
  }
}

________________________________

From: kathy walsh [mailto:Kathleen.Walsh_at_Sun.COM]
Sent: Monday, October 11, 2004 11:59 AM
To: users_at_jax-rpc.dev.java.net
Subject: Re: DII client: IndexOutOfBoundsException when calling method with 0 argument


Hello,
Please send your dii client program or a dii program
that reproduces this problem and I will take a look-
Kathy

Abhishek Agrawal wrote:

        I am trying to call "GetLondonGoldAndSilverFix" method on the "LondonGoldAndSilverFix" (http://www.webservicex.net/LondonGoldFix.asmx?WSDL <http://www.webservicex.net/LondonGoldFix.asmx?WSDL> )
        
        This perticular method does not take any parameter and hence in my DII client I am not calling method
        call.addParameter()
        
        But somehow DII client does not like it and seems like its alwaysexpecting at least 1 parameter.
        I get the following exception when I try to call invoke.
        
        java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:507)
        at java.util.ArrayList.get(ArrayList.java:324)
        at com.sun.xml.rpc.client.dii.BasicCall.createLiteralRequestSerializer(BasicCall.java:652)
        at com.sun.xml.rpc.client.dii.BasicCall.getRequestSerializer(BasicCall.java:621)
        at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:473)
        at com.appiancorp.process.runtime.activities.WebServiceActivity.doCall(WebServiceActivity.java:308)
        at com.appiancorp.process.runtime.activities.WebServiceActivity.main(WebServiceActivity.java:119)
        
        
        The DII client works fine for functions that take one or more parameters (Obviously, I have not been able to run it for complex types, but thatýs a different story..)
        
        Has anyone else noticed this problem?
        
        Thanks !


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net