You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by an...@apache.org on 2002/11/18 15:07:01 UTC

cvs commit: xml-axis-wsif/java/samples/clients DynamicInvoker.java

antelder    2002/11/18 06:07:01

  Modified:    java/samples/clients DynamicInvoker.java
  Log:
  Fix the DynamicInvokerSample to work with simple .Net doc style services
  
  Revision  Changes    Path
  1.6       +31 -3     xml-axis-wsif/java/samples/clients/DynamicInvoker.java
  
  Index: DynamicInvoker.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/clients/DynamicInvoker.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DynamicInvoker.java	29 Jul 2002 13:40:04 -0000	1.5
  +++ DynamicInvoker.java	18 Nov 2002 14:07:01 -0000	1.6
  @@ -67,16 +67,17 @@
   import javax.wsdl.Operation;
   import javax.wsdl.Output;
   import javax.wsdl.Part;
  +import javax.wsdl.Port;
   import javax.wsdl.PortType;
   import javax.wsdl.Service;
   import javax.xml.namespace.QName;
   
  +import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFMessage;
   import org.apache.wsif.WSIFOperation;
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.WSIFService;
   import org.apache.wsif.WSIFServiceFactory;
  -import org.apache.wsif.base.WSIFServiceImpl;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
   import org.apache.wsif.util.WSIFPluggableProviders;
   import org.apache.wsif.util.WSIFUtils;
  @@ -134,7 +135,7 @@
   
           try {
               portName =
  -                operationName.substring(operationName.indexOf("("), operationName.indexOf(")"));
  +                operationName.substring(operationName.indexOf("(")+1, operationName.indexOf(")"));
               operationName = operationName.substring(0, operationName.indexOf("("));
           } catch (Exception ignored) {
           }
  @@ -150,7 +151,7 @@
                   operationName,
                   inputName,
                   outputName,
  -                null,
  +                portName,
                   protocol,
                   args,
                   shift);
  @@ -195,6 +196,16 @@
           System.out.println("Preparing WSIF dynamic invocation");
   
           Service service = WSIFUtils.selectService(def, serviceNS, serviceName);
  +        if (portName != null) {
  +           Port p = service.getPort(portName);
  +           if (p!=null) {
  +              QName pn = p.getBinding().getQName();
  +              if (pn!=null) {
  +                 portTypeName = pn.getLocalPart();
  +                 portTypeNS = pn.getNamespaceURI();
  +              }
  +           }
  +        }
           PortType portType = WSIFUtils.selectPortType(def, portTypeNS, portTypeName);
   
           WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  @@ -265,6 +276,7 @@
               Class[] inTypes = new Class[0];
               if (opInput != null) {
                   List parts = opInput.getMessage().getOrderedParts(null);
  +                unWrapIfWrappedDocLit(parts, name, def);
                   int count = parts.size();
                   inNames = new String[count];
                   inTypes = new Class[count];
  @@ -296,6 +308,7 @@
               Output opOutput = op.getOutput();
               if (opOutput != null) {
                   List parts = opOutput.getMessage().getOrderedParts(null);
  +                unWrapIfWrappedDocLit(parts, name+"Response", def);
                   int count = parts.size();
                   outNames = new String[count];
                   outTypes = new Class[count];
  @@ -333,6 +346,9 @@
               names[i] = part.getName();
               QName partType = part.getTypeName();
               if (partType == null) {
  +               partType = part.getElementName();
  +            }
  +            if (partType == null) {
                   throw new RuntimeException(
                       "part " + names[i] + " must have type name declared");
               }
  @@ -355,5 +371,17 @@
               }
           }
       }
  +
  +	/**
  +	 * Unwraps the top level part if this a wrapped DocLit message.
  +	 */
  +	private static void unWrapIfWrappedDocLit(List parts, String operationName, Definition def) throws WSIFException {
  +		   Part p = WSIFUtils.getWrappedDocLiteralPart(parts, operationName);
  +		   if (p != null) {
  +			  List unWrappedParts = WSIFUtils.unWrapPart(p, def);
  +			  parts.remove(p);
  +			  parts.addAll(unWrappedParts);
  +		   }
  +	}
   
   }