antelder    2002/12/02 05:26:21

  Modified:    java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFPort_ApacheAxis.java
                        WSIFDynamicProvider_ApacheAxis.java
                        WSIFJmsTransport.java
  Added:       java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFAXISConstants.java
  Log:
  Phase 2 of tidying up the AXIS provider
  
  Revision  Changes    Path
  1.19      +548 -704  
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java
  
  Index: WSIFPort_ApacheAxis.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- WSIFPort_ApacheAxis.java  19 Nov 2002 09:41:25 -0000      1.18
  +++ WSIFPort_ApacheAxis.java  2 Dec 2002 13:26:20 -0000       1.19
  @@ -63,29 +63,17 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  -import java.util.Vector;
   
   import javax.wsdl.Binding;
  -import javax.wsdl.BindingFault;
  -import javax.wsdl.BindingInput;
   import javax.wsdl.BindingOperation;
  -import javax.wsdl.BindingOutput;
   import javax.wsdl.Definition;
   import javax.wsdl.Input;
   import javax.wsdl.Operation;
   import javax.wsdl.Output;
   import javax.wsdl.Port;
   import javax.wsdl.PortType;
  -import javax.wsdl.Service;
  -import javax.wsdl.extensions.mime.MIMEContent;
  -import javax.wsdl.extensions.mime.MIMEMimeXml;
  -import javax.wsdl.extensions.mime.MIMEMultipartRelated;
  -import javax.wsdl.extensions.mime.MIMEPart;
   import javax.wsdl.extensions.soap.SOAPAddress;
   import javax.wsdl.extensions.soap.SOAPBinding;
  -import javax.wsdl.extensions.soap.SOAPBody;
  -import javax.wsdl.extensions.soap.SOAPFault;
  -import javax.wsdl.extensions.soap.SOAPHeader;
   import javax.wsdl.extensions.soap.SOAPOperation;
   import javax.xml.namespace.QName;
   import javax.xml.rpc.JAXRPCException;
  @@ -99,14 +87,9 @@
   import org.apache.wsif.logging.Trc;
   import org.apache.wsif.providers.WSIFDynamicTypeMap;
   import org.apache.wsif.util.WSIFProperties;
  -import org.apache.wsif.util.WSIFUtils;
   import org.apache.wsif.util.jms.WSIFJMSDestination;
   import org.apache.wsif.util.jms.WSIFJMSFinder;
   import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
  -import org.apache.wsif.wsdl.extensions.jms.JMSProperty;
  -import org.apache.wsif.wsdl.extensions.jms.JMSPropertyValue;
  -
  -import com.ibm.wsdl.extensions.mime.MIMEConstants;
   
   /**
    * @author Mark Whitlock <[EMAIL PROTECTED]>
  @@ -114,695 +97,556 @@
    */
   public class WSIFPort_ApacheAxis extends WSIFDefaultPort {
   
  -     private static final long serialVersionUID = 1L;
  +     private static final long serialVersionUID = 2L;
  +
  +     protected Definition definition;
  +     protected Port port;
  +     protected SOAPBinding soapBinding;
  +     protected SOAPAddress soapAddress;
  +     protected JMSAddress jmsAddress;
  +
  +     protected String bindingStyle;
  +     protected URL endPointURL;
  +     protected List jmsAddressPropVals;
  +
  +     protected WSIFDynamicTypeMap wsifdynamictypemap;
  +     protected Map operationInstances;
  +
  +     transient protected Transport transport;
  +     transient protected Call call;
  +
  +     private static final String HTTP_TRANSPORT_URI =
  +             WSIFAXISConstants.HTTP_TRANSPORT_URI;
  +     private static final String JMS_TRANSPORT_URI =
  +             WSIFAXISConstants.JMS_TRANSPORT_URI;
  +
  +     /**
  +      * Construct a new WSIFPort
  +      */
  +     public WSIFPort_ApacheAxis(
  +             Definition definition,
  +             Port port,
  +             SOAPBinding soapBinding,
  +             WSIFDynamicTypeMap wsifdynamictypemap)
  +             throws WSIFException {
  +             Trc.entry(this, definition, port, soapBinding, wsifdynamictypemap);
  +
  +             this.definition = definition;
  +             this.port = port;
  +             this.soapBinding = soapBinding;
  +             this.wsifdynamictypemap = wsifdynamictypemap;
  +
  +             initializeSoapBinding();
  +             initializeServiceAddress();
  +             operationInstances = new HashMap();
  +
  +             if (Trc.ON)
  +                     Trc.exit(deep());
  +     }
  +
  +     /**
  +      * Gets the soap:binding WSDL element and validates its attributes
  +      */
  +     private void initializeSoapBinding() throws WSIFException {
  +             this.bindingStyle = soapBinding.getStyle();
  +             if (bindingStyle == null || bindingStyle.length() < 1) {
  +                     bindingStyle = WSIFAXISConstants.STYLE_DOCUMENT;
  +             } else if (!WSIFAXISConstants.VALID_STYLES.contains(bindingStyle)) {
  +                     throw new WSIFException(
  +                             "unsupported style '"
  +                                     + bindingStyle
  +                                     + "' for binding:"
  +                                     + soapBinding);
  +             }
  +
  +             String transportURI = soapBinding.getTransportURI();
  +             if (!WSIFAXISConstants.VALID_TRANSPORTS.contains(transportURI)) {
  +                     throw new WSIFException(
  +                             "unsupported transport '"
  +                                     + transportURI
  +                                     + "' for binding: "
  +                                     + soapBinding);
  +             }
  +     }
  +
  +     /**
  +      * Gets the soap:address or jms:address WSDL element from the service port
  +      * and validates it against the binding transport. 
  +      */
  +     private void initializeServiceAddress() throws WSIFException {
  +             this.soapAddress =
  +                     (SOAPAddress) getExtElem(port,
  +                             SOAPAddress.class,
  +                             port.getExtensibilityElements());
  +             this.jmsAddress =
  +                     (JMSAddress) getExtElem(port,
  +                             JMSAddress.class,
  +                             port.getExtensibilityElements());
  +
  +             if (soapAddress != null && jmsAddress != null)
  +                     throw new WSIFException(
  +                             "Both soap:address and jms:address cannot be specified 
for port "
  +                                     + port);
  +
  +             if (soapAddress == null && jmsAddress == null)
  +                     throw new WSIFException(
  +                             "Either soap:address or jms:address must be specified 
for port "
  +                                     + port);
  +
  +             if (isTransportHTTP() && soapAddress == null) {
  +                     throw new WSIFException(
  +                             "binding transport "
  +                                     + HTTP_TRANSPORT_URI
  +                                     + " requires soap:address for port "
  +                                     + port);
  +             }
  +
  +             if (isTransportJMS() && jmsAddress == null) {
  +                     throw new WSIFException(
  +                             "binding transport "
  +                                     + JMS_TRANSPORT_URI
  +                                     + " requires jms:address for port "
  +                                     + port);
  +             }
   
  -    protected Map operationInstances;
  -    protected Port port;
  -    protected Definition definition;
  -    protected URL url = null;
  -    protected int transportcode;
  -    protected Transport st;
  -    protected List jmsAddressPropVals = null;
  -    protected Call call;
  -    protected String style;
  -
  -    private static final int HTTP_TRANSPORT = 1;
  -    private static final int JMS_TRANSPORT = 2;
  -    private static final int MQJMS_TRANSPORT = 3;
  -    private static final String CONTEXT_FACTORY = "contextFactory";
  -    private static final String PROVIDER_URL = "providerURL";
  -    private static final String FACTORY = "factory";
  -    private static final String REPLY_QUEUE = "replyQueue";
  -    private static final String HOST = "host";
  -    private static final String CHANNEL = "channel";
  -    private static final String PORT = "port";
  -    private static final String CCSID = "ccsid";
  -
  -    public WSIFPort_ApacheAxis(
  -        Definition definition1,
  -        Service service,
  -        Port port1,
  -        WSIFDynamicTypeMap wsifdynamictypemap)
  -        throws WSIFException {
  -        Trc.entry(this, definition, service, port1, wsifdynamictypemap);
  -
  -        operationInstances = new HashMap();
  -        setDefinition(definition1);
  -        setPort(port1);
  -
  -        JMSAddress jmsaddress =
  -            (JMSAddress) getExtElem(port1,
  -                JMSAddress.class,
  -                port1.getExtensibilityElements());
  -        SOAPAddress soapaddress =
  -            (SOAPAddress) getExtElem(port1,
  -                SOAPAddress.class,
  -                port1.getExtensibilityElements());
  -
  -        if (soapaddress != null && jmsaddress != null)
  -            throw new WSIFException(
  -                "Both soap:address and jms:address cannot be specified for port " + 
port);
  -
  -        if (soapaddress == null && jmsaddress == null)
  -            throw new WSIFException(
  -                "Either soap:address or jms:address must be specified for port " + 
port);
  -
  -        boolean isNotHTTP = false;
  -        if (soapaddress != null) {
  -            String s = soapaddress.getLocationURI();
  -            try {
  -                url = new URL(s);
  -            } catch (MalformedURLException malformedurlexception) {
  -                     Trc.exception(malformedurlexception);
  -                throw new WSIFException(
  -                    "could not set SOAP address to " + s,
  -                    malformedurlexception);
  -            }
  -        } else {
  -            isNotHTTP = true;
  -            jmsAddressPropVals = jmsaddress.getJMSPropertyValues();
  -        }
  -
  -        if (url == null && !isNotHTTP)
  -            throw new WSIFException(
  -                "soap:address with location URI is required for " + port1);
  -        String s1 = null;
  -        Binding binding = port1.getBinding();
  -        SOAPBinding soapbinding =
  -            (SOAPBinding) getExtElem(binding,
  -                javax.wsdl.extensions.soap.SOAPBinding.class,
  -                binding.getExtensibilityElements());
  -        if (soapbinding != null) {
  -            s1 = soapbinding.getStyle();
  -            if (!"rpc".equals(s1) && !"document".equals(s1))
  -                throw new WSIFException("unsupported style " + s1 + " for " + 
soapbinding);
  -            String s2 = soapbinding.getTransportURI();
  -            if ("http://schemas.xmlsoap.org/soap/http".equals(s2)) {
  -                transportcode = HTTP_TRANSPORT;
  -                st = new HTTPTransport();
  -            } else if ("http://schemas.xmlsoap.org/soap/jms".equals(s2)) {
  -                transportcode = JMS_TRANSPORT;
  -                st = new WSIFJmsTransport();
  -                //   HACK            } else if 
("http://schemas.xmlsoap.org/soap/mqjms".equals(s2)) {
  -                //   HACK                    transportcode = MQJMS_TRANSPORT;
  -                //   HACK                    st = new MQJMSTransport();
  -            } else {
  -                throw new WSIFException("unsupported transport " + s2 + " for " + 
soapbinding);
  -            }
  -        }
  -
  -        if (transportcode == JMS_TRANSPORT) {
  -            WSIFJMSDestination jmsDestination =
  -                new WSIFJMSDestination(
  -                    WSIFJMSFinder.newFinder(jmsaddress,port.getName()),
  -                    jmsaddress.getJmsProvDestName(),
  -                    WSIFProperties.getSyncTimeout());
  -
  -            ((WSIFJmsTransport) st).setDestination(jmsDestination);
  -        }
  -
  -        if (s1 == null) {
  -            style = "document";
  -        } else {
  -             style = s1;
  -        }
  -        PortType porttype = binding.getPortType();
  -        List list = porttype.getOperations();
  -        Operation operation;
  -        WSIFOperation_ApacheAxis wsifoperation_apacheaxis;
  -        for (Iterator iterator = list.iterator();
  -            iterator.hasNext();
  -            setDynamicWSIFOperation(
  -                operation.getName(),
  -                operation.getInput().getName(),
  -                operation.getOutput() == null ? null : 
operation.getOutput().getName(),
  -                wsifoperation_apacheaxis)) {
  -                     
  -            operation = (Operation) iterator.next();
  -            String opName = operation.getName();
  -            Input input = operation.getInput();
  -            Output output = operation.getOutput();
  -            if (input == null)
  -                throw new WSIFException("missing input message for operation " + 
opName);
  -            wsifoperation_apacheaxis =
  -                new WSIFOperation_ApacheAxis(this, operation, wsifdynamictypemap);
  -
  -            if (jmsAddressPropVals!=null && jmsAddressPropVals.size()>0) {
  -                if (transportcode==JMS_TRANSPORT)
  -                    
wsifoperation_apacheaxis.addInputJmsPropertyValues(jmsAddressPropVals);
  -                else throw new WSIFException("jms:propertyValue found in non-jms 
address");
  -            }
  -                
  -            BindingOperation bindingoperation =
  -               WSIFUtils.getBindingOperation( binding, operation );
  -            if (bindingoperation == null)
  -                throw new WSIFException(
  -                    "missing required in WSDL 1.1 binding operation for " + opName);
  -            SOAPOperation soapoperation =
  -                (SOAPOperation) getExtElem(bindingoperation,
  -                    javax.wsdl.extensions.soap.SOAPOperation.class,
  -                    bindingoperation.getExtensibilityElements());
  -            if (soapoperation == null)
  -                throw new WSIFException(
  -                    "soapAction must be specified in  required by WSDL 1.1 
soap:operation binding for "
  -                        + bindingoperation);
  -            String s4 = soapoperation.getSoapActionURI();
  -            wsifoperation_apacheaxis.setSoapActionURI(s4);
  -            String s5 = soapoperation.getStyle();
  -            if (s5 != null && !"rpc".equals(s5) && !"document".equals(s5))
  -                throw new WSIFException("unsupported style " + s1 + " for operation 
" + opName);
  -            if (!"rpc".equals(s1) && !"document".equals(s1))
  -                throw new WSIFException(
  -                    "default soap style must be rpc or document if operation "
  -                        + opName
  -                        + " binding has not style property");
  -            if (s5 != null) {
  -             style = s5;
  -            }
  -            QName bindingQN = binding.getQName();
  -            if (bindingQN != null) {
  -               
wsifoperation_apacheaxis.setInputNamespace(bindingQN.getNamespaceURI());
  -            }
  -            BindingInput bindinginput = bindingoperation.getBindingInput();
  -            List inExtElems = bindinginput.getExtensibilityElements();
  -            SOAPBody inSoapBody =
  -                (SOAPBody) getExtElem(bindinginput,
  -                    javax.wsdl.extensions.soap.SOAPBody.class,
  -                    inExtElems);
  -            if (inSoapBody != null) {
  -                List list2 =
  -                    parseSoapBody(
  -                        wsifoperation_apacheaxis,
  -                        soapoperation,
  -                        inSoapBody,
  -                        true);
  -                wsifoperation_apacheaxis.setSoapPartNames(list2);
  -            }
  -            
  -            MIMEMultipartRelated inMimeMultipart =
  -                (MIMEMultipartRelated) getExtElem(bindinginput,
  -                    MIMEMultipartRelated.class,
  -                    inExtElems);
  -            if (inSoapBody != null && inMimeMultipart != null)
  -                throw new WSIFException(
  -                    "In a binding operation that contains a mime:multipartRelated, "
  -                        + "a soap:body was found that was not in a mime:part. "
  -                        + "OperationName="
  -                        + opName);
  -            if (inMimeMultipart != null)
  -                parseMimeMultipart(
  -                    inMimeMultipart,
  -                    bindingoperation,
  -                    wsifoperation_apacheaxis,
  -                    soapoperation,
  -                    true,
  -                    opName);
  -            
  -            MIMEMimeXml inMimeMimeXml =
  -                (MIMEMimeXml) getExtElem(bindinginput,
  -                    MIMEMimeXml.class,
  -                    inExtElems);
  -            if (inMimeMimeXml != null)
  -                throw new WSIFException(
  -                    "WSIF does not support mime:mimeXml. Operation=" + opName);
  -
  -            SOAPHeader soapheader =
  -                (SOAPHeader) getExtElem(bindinginput,
  -                    javax.wsdl.extensions.soap.SOAPHeader.class,
  -                    bindinginput.getExtensibilityElements());
  -            if (soapheader != null)
  -                throw new WSIFException("not supported input soap:header " + 
soapheader);
  -
  -            List inJmsProps =
  -                getExtElems(
  -                    bindinginput,
  -                    JMSProperty.class,
  -                    bindinginput.getExtensibilityElements());
  -            if (inJmsProps != null && inJmsProps.size() > 0) {
  -                if (st instanceof WSIFJmsTransport)
  -                    wsifoperation_apacheaxis.setInputJmsProperties(inJmsProps);
  -                else
  -                    throw new WSIFException("jms:properties found in non-jms 
binding");
  -            }
  -
  -            List inJmsPropVals = 
  -                getExtElems(bindinginput, JMSPropertyValue.class, 
bindinginput.getExtensibilityElements());
  -            if (inJmsPropVals!=null && inJmsPropVals.size()>0) {
  -                if (st instanceof WSIFJmsTransport) 
  -                    
wsifoperation_apacheaxis.addInputJmsPropertyValues(inJmsPropVals);
  -                else throw new WSIFException("jms:propertyValue found in non-jms 
binding");
  -            }
  -
  -            BindingOutput bindingoutput = bindingoperation.getBindingOutput();
  -            if (bindingoutput != null) {
  -                List outExtElems = bindingoutput.getExtensibilityElements();
  -                SOAPBody outSoapBody =
  -                    (SOAPBody) getExtElem(bindingoutput,
  -                        javax.wsdl.extensions.soap.SOAPBody.class,
  -                        outExtElems);
  -                if (outSoapBody != null) {
  -                    List list3 =
  -                        parseSoapBody(
  -                            wsifoperation_apacheaxis,
  -                            soapoperation,
  -                            outSoapBody,
  -                            false);
  -                    if (list3 != null && list3.size() > 0)
  -                        wsifoperation_apacheaxis.setReturnName((String) 
list3.get(0));
  -                }
  -
  -                MIMEMultipartRelated outMimeMultipart =
  -                    (MIMEMultipartRelated) getExtElem(bindingoutput,
  -                        MIMEMultipartRelated.class,
  -                        outExtElems);
  -                if (outSoapBody != null && outMimeMultipart != null)
  -                    throw new WSIFException(
  -                        "In a binding operation that contains a 
mime:multipartRelated, "
  -                            + "a soap:body was found that was not in a mime:part. "
  -                            + "OperationName="
  -                            + opName);
  -                if (outMimeMultipart != null)
  -                    parseMimeMultipart(
  -                        outMimeMultipart,
  -                        bindingoperation,
  -                        wsifoperation_apacheaxis,
  -                        soapoperation,
  -                        false,
  -                        opName);
  -
  -                MIMEMimeXml outMimeMimeXml =
  -                    (MIMEMimeXml) getExtElem(bindingoutput,
  -                        MIMEMimeXml.class,
  -                        outExtElems);
  -                if (outMimeMimeXml != null)
  -                    throw new WSIFException(
  -                        "WSIF does not support mime:mimeXml. Operation=" + opName);
  -
  -                soapheader =
  -                    (SOAPHeader) getExtElem(bindingoutput,
  -                        javax.wsdl.extensions.soap.SOAPHeader.class,
  -                        outExtElems);
  -                if (soapheader != null)
  -                    throw new WSIFException("not supported output soap:header " + 
soapheader);
  -                for (Iterator iterator1 =
  -                    bindingoperation.getBindingFaults().values().iterator();
  -                    iterator1.hasNext();
  -                    ) {
  -                    BindingFault bindingfault = (BindingFault) iterator1.next();
  -                    SOAPFault soapfault =
  -                        (SOAPFault) getExtElem(bindingfault,
  -                            javax.wsdl.extensions.soap.SOAPFault.class,
  -                            bindingfault.getExtensibilityElements());
  -                }
  -                List outJmsProps =
  -                    getExtElems(
  -                        bindingoutput,
  -                        JMSProperty.class,
  -                        outExtElems);
  -                if (outJmsProps != null && outJmsProps.size() > 0) {
  -                    if (st instanceof WSIFJmsTransport)
  -                        
wsifoperation_apacheaxis.setOutputJmsProperties(outJmsProps);
  -                    else
  -                        throw new WSIFException("jms:properties found in non-jms 
binding");
  -                }
  -            }
  -
  -        }
  -
  -        if (Trc.ON)
  -            Trc.exit(deep());
  -    }
  -
  -    
  -    private List parseSoapBody(
  -        WSIFOperation_ApacheAxis op,
  -        SOAPOperation soapoperation,
  -        SOAPBody soapbody,
  -        boolean isInput)
  -        throws WSIFException {
  -
  -        Trc.entry(this, op, soapoperation, soapbody, new Boolean(isInput));
  -
  -        if (isInput) {
  -            String ns = soapbody.getNamespaceURI();
  -            if (ns != null) { 
  -               op.setInputNamespace(soapbody.getNamespaceURI());
  -            }
  -        }
  -
  -        String use = soapbody.getUse();
  -        if (!"encoded".equals(use) && !"literal".equals(use))
  -            throw new WSIFException(
  -                "unsupported use " + use + " in " + soapoperation);
  -
  -        if (isInput) {
  -            List list1 = soapbody.getEncodingStyles();
  -            if (list1 != null && list1.size() > 0)
  -                op.setInputEncodingStyle((String) list1.get(0));
  -        }
  -
  -        List list2 = soapbody.getParts();
  -        Trc.exit(list2);
  -        return list2;
  -    }
  -    
  -    private void parseMimeMultipart(
  -        MIMEMultipartRelated mimeMultipart,
  -        BindingOperation bindingoperation,
  -        WSIFOperation_ApacheAxis wsifoperation_apacheaxis,
  -        SOAPOperation soapoperation,
  -        boolean isInput,
  -        String operationName)
  -        throws WSIFException {
  -
  -        Trc.entry(
  -            this,
  -            mimeMultipart,
  -            bindingoperation,
  -            wsifoperation_apacheaxis,
  -            soapoperation);
  -     
  -        Vector mimePartNames = new Vector();
  -        boolean soapBodyFound = false;
  -        Operation op = bindingoperation.getOperation();
  -        Map mapInParts = op.getInput().getMessage().getParts();
  -        Map mapOutParts =
  -            op.getOutput() == null
  -                ? new HashMap()
  -                : op.getOutput().getMessage().getParts();
  -
  -        List mimeParts = mimeMultipart.getMIMEParts();
  -        Iterator mimePartIt = mimeParts.iterator();
  -        while (mimePartIt.hasNext()) {
  -            Object nextMimePart = mimePartIt.next();
  -            if (nextMimePart instanceof MIMEPart) {
  -                MIMEPart mimePart = (MIMEPart) nextMimePart;
  -                if (!MIMEConstants
  -                    .NS_URI_MIME
  -                    .equals(mimePart.getElementType().getNamespaceURI()))
  -                    throw new WSIFException(
  -                        "A MIME part in binding operation "
  -                            + bindingoperation.getName()
  -                            + " did not have the correct namespace URI of "
  -                            + MIMEConstants.NS_URI_MIME
  -                            + ".");
  -
  -                boolean containsSoapBody = false;
  -                boolean containsMimeContent = false;
  -                List mimePartChildren = mimePart.getExtensibilityElements();
  -                Iterator mimePartChildrenIt = mimePartChildren.iterator();
  -                while (mimePartChildrenIt.hasNext()) {
  -                    Object nextChild = mimePartChildrenIt.next();
  -                    if (nextChild instanceof MIMEContent) {
  -                        MIMEContent mimeContent = (MIMEContent) nextChild;
  -                        if (!MIMEConstants
  -                            .NS_URI_MIME
  -                            .equals(
  -                                mimePart.getElementType().getNamespaceURI()))
  -                            throw new WSIFException(
  -                                "A MIME part in binding operation "
  -                                    + bindingoperation.getName()
  -                                    + " did not have the correct namespace URI of "
  -                                    + MIMEConstants.NS_URI_MIME
  -                                    + ".");
  -                        containsMimeContent = true;
  -                        if (containsSoapBody)
  -                            throw new WSIFException(
  -                                "A mime:part that contains a mime:content also "
  -                                    + "contains a soap:body. Operation="
  -                                    + operationName);
  -
  -                        String partName = mimeContent.getPart();
  -                        if (partName == null || partName.length() == 0)
  -                            throw new WSIFException(
  -                                "No part name for a mime:content. Operation="
  -                                    + operationName);
  -                                    
  -                        if ((isInput && mapInParts.get(partName) == null)
  -                            || (!isInput && mapOutParts.get(partName) == null))
  -                            throw new WSIFException(
  -                                "The part specified in a mime:content does "
  -                                    + "not exist in the operation. Operation="
  -                                    + operationName
  -                                    + " Part="
  -                                    + partName);
  -
  -                        mimePartNames.addElement(partName);
  -
  -                    } else if (nextChild instanceof SOAPBody) {
  -                        if (soapBodyFound)
  -                            throw new WSIFException(
  -                                "Multiple soap:body tags found in a "
  -                                    + "mime:multipartRelated. Operation="
  -                                    + operationName);
  -                        soapBodyFound = true;
  -                        containsSoapBody = true;
  -                        if (containsMimeContent)
  -                            throw new WSIFException(
  -                                "A mime:part that contains a mime:content also "
  -                                    + "contains a soap:body. Operation="
  -                                    + operationName);
  -
  -                        List soapPartNameList =
  -                            parseSoapBody(
  -                                wsifoperation_apacheaxis,
  -                                soapoperation,
  -                                (SOAPBody) nextChild,
  -                                isInput);
  -
  -                        if (isInput)
  -                            wsifoperation_apacheaxis.setSoapPartNames(
  -                                soapPartNameList);
  -                        else if (
  -                            soapPartNameList != null
  -                                && soapPartNameList.size() > 0)
  -                            wsifoperation_apacheaxis.setReturnName(
  -                                (String) soapPartNameList.get(0));
  -                    } else if (nextChild instanceof MIMEMultipartRelated) {
  -                        throw new WSIFException(
  -                            "WSIF does not support nesting mime:multipartRelated "
  -                                + "inside a mime:part. Operation="
  -                                + operationName);
  -                    } else if (nextChild instanceof MIMEMimeXml) {
  -                        throw new WSIFException(
  -                            "WSIF does not support mime:mimeXml. Operation="
  -                                + operationName);
  -                    }
  -                }
  -            }
  -        }
  -
  -        if (!soapBodyFound)
  -            throw new WSIFException(
  -                "No soap:body found in a mime:multipartRelated. Operation="
  -                    + operationName);
  -
  -        if (mimePartNames != null && !mimePartNames.isEmpty()) {
  -            List oldMimePartNames = wsifoperation_apacheaxis.getMimePartNames();
  -            if (oldMimePartNames == null || oldMimePartNames.isEmpty())
  -                wsifoperation_apacheaxis.setMimePartNames(mimePartNames);
  -            else
  -                oldMimePartNames.addAll(mimePartNames);
  -        }
  -
  -        Trc.exit();
  -    }
  -
  -    public Definition getDefinition() {
  -        Trc.entry(this);
  -        Trc.exit(definition);
  -        return definition;
  -    }
  -
  -    public WSIFOperation_ApacheAxis getDynamicWSIFOperation(
  -        String name,
  -        String inputName,
  -        String outputName) 
  -        throws WSIFException {
  -        Trc.entry(this, name, inputName, outputName);
  -        
  -        WSIFOperation_ApacheAxis tempOp =
  -            (WSIFOperation_ApacheAxis) operationInstances.get(
  -                getKey(name, inputName, outputName));
  +             if (soapAddress != null) {
  +                     String s = soapAddress.getLocationURI();
  +                     if (s == null || s.length() < 1) {
  +                             throw new WSIFException(
  +                                     "soap:address with location URI is required 
for " + port);
  +                     }
  +                     try {
  +                             this.endPointURL = new URL(s);
  +                     } catch (MalformedURLException e) {
  +                             Trc.exception(e);
  +                             throw new WSIFException(
  +                                     "exception setting SOAP address to "
  +                                             + s
  +                                             + ": "
  +                                             + e.getLocalizedMessage(),
  +                                     e);
  +                     }
  +             } else {
  +                     this.jmsAddressPropVals = jmsAddress.getJMSPropertyValues();
  +             }
  +     }
  +
  +     /**
  +      * Creates a WSIFOperation for the given operation name
  +      * @return WSIFOperation   the WSIFOperation
  +      * @see WSIFOperation.createOperation 
  +      */
  +     public WSIFOperation createOperation(String operationName)
  +             throws WSIFException {
  +             Trc.entry(this, operationName);
  +             WSIFOperation wo = createOperation(operationName, null, null);
  +             Trc.exit(wo);
  +             return wo;
  +     }
  +
  +     /**
  +      * Creates a WSIFOperation for the given operation name
  +      * @return WSIFOperation   the WSIFOperation
  +      * @see WSIFOperation.createOperation 
  +      */
  +     public WSIFOperation createOperation(
  +             String operationName,
  +             String inputName,
  +             String outputName)
  +             throws WSIFException {
  +             Trc.entry(this, operationName, inputName, outputName);
  +
  +             WSIFOperation_ApacheAxis op =
  +                     getDynamicWSIFOperation(operationName, inputName, outputName);
  +             if (op == null) {
  +                     throw new WSIFException(
  +                             "Could not create operation: "
  +                                     + operationName
  +                                     + ":"
  +                                     + inputName
  +                                     + ":"
  +                                     + outputName);
  +             }
  +             WSIFOperation wo = op.copy();
  +             Trc.exit(wo);
  +             return wo;
  +     }
  +
  +     /**
  +      * Closes the port. 
  +      * All methods are invalid after calling this method.
  +      */
  +     public void close() throws WSIFException {
  +             Trc.entry(this);
  +             if (transport != null && transport instanceof WSIFJmsTransport) {
  +                     ((WSIFJmsTransport) transport).close();
  +             }
  +             Trc.exit();
  +     }
  +
  +     /**
  +      * @deprecated replaced by getTransport 
  +      */
  +     public Transport getAxisTransport() throws WSIFException {
  +             Trc.entry(this);
  +             Transport t = getTransport();
  +             Trc.exit(t);
  +             return t;
  +     }
  +
  +     /**
  +      * Gets the QName of the WSDL Binding
  +      * @return QName   the name of the Binding
  +      */
  +     public QName getBindingName() {
  +             Trc.entry(this);
  +             Binding binding = port.getBinding();
  +             QName bindingQN = binding.getQName();
  +             Trc.exit(bindingQN);
  +             return bindingQN;
  +     }
  +
  +     /**
  +      * Returns the style attribute of this Binding.
  +      * @return String   the style attribute
  +      */
  +     public String getBindingStyle() {
  +             Trc.entry(this);
  +             Trc.exit(bindingStyle);
  +             return bindingStyle;
  +     }
  +
  +     /**
  +      * Gets the AXIS Call object being used by this WSIFPort 
  +      * @return Call   the AXIS Call object
  +      */
  +     public Call getCall() throws WSIFException {
  +             Trc.entry(this);
  +             if (call == null) {
  +                     Transport axistransport = getTransport();
  +                     java.net.URL url = getEndPoint();
  +                     try {
  +                             if (url != null) {
  +                                     call = new Call(url);
  +                                     if (axistransport != null) {
  +                                             axistransport.setUrl(url.toString());
  +                                     }
  +                             } else
  +                                     call = new Call(new 
org.apache.axis.client.Service());
  +                     } catch (JAXRPCException e) {
  +                             Trc.exception(e);
  +                             throw new WSIFException(
  +                                     "exception creating call object: "
  +                                             + e.getLocalizedMessage(),
  +                                     e);
  +                     }
  +             }
  +             call.setMaintainSession(true);
  +             Trc.exit(call);
  +             return call;
  +     }
  +
  +     /**
  +      * Returns the Definition object for the WSDL file 
  +      * @return Definition   the WSDL4J Definition object
  +      */
  +     public Definition getDefinition() {
  +             Trc.entry(this);
  +             Trc.exit(definition);
  +             return definition;
  +     }
  +
  +     /**
  +      * @deprecated replaced by the createOperation methods
  +      */ //TODO make this private or merge into createOp method
  +     public WSIFOperation_ApacheAxis getDynamicWSIFOperation(
  +             String name,
  +             String inputName,
  +             String outputName)
  +             throws WSIFException {
  +             Trc.entry(this, name, inputName, outputName);
  +
  +             WSIFOperation_ApacheAxis wsifOperation = null;
  +
  +             WSIFOperation_ApacheAxis tempOp =
  +                     (WSIFOperation_ApacheAxis) operationInstances.get(
  +                             getKey(name, inputName, outputName));
   
  -        WSIFOperation_ApacheAxis operation = null;
                if (tempOp != null) {
  -                     operation = tempOp.copy();
  +                     wsifOperation = tempOp.copy();
                }
  -        
  -        if (operation == null) {
  -            BindingOperation bindingOperationModel =
  -                port.getBinding().getBindingOperation(name, inputName, outputName);
  -
  -            if (bindingOperationModel != null) {
  -                // Only one operation matched in binding so find it in instances
  -                // from all the information that is available to us
  -                Iterator i = operationInstances.keySet().iterator();
  -                while (i.hasNext()) {
  -                    String key = (String) i.next();
  -                    if ((outputName != null && key.endsWith(outputName)) || 
outputName == null) {
  -                        String start = (inputName == null) ? name + ":" : name + 
":" + inputName;
  -                        if (key.startsWith(start)) {
  -                            if (operation != null) {
  -                                // Duplicate operation found based on names!
  -                                operation = null;
  -                                break;
  -                            }
  -                            operation = (WSIFOperation_ApacheAxis) 
operationInstances.get(key);
  -                        }
  -                    }
  -                }
  -            }
  -        }
  -        if (operation != null ) {
  -             operation.setStyle(style);
  -        }
  -
  -        Trc.exit(operation);
  -        return operation;
  -    }
  -
  -    public URL getEndPoint() {
  -        Trc.entry(this);
  -        Trc.exit(url);
  -        return url;
  -    }
  -
  -    public Port getPort() {
  -        Trc.entry(this);
  -        Trc.exit(port);
  -        return port;
  -    }
  -
  -    public Transport getAxisTransport() {
  -        Trc.entry(this);
  -        Trc.exit(st);
  -        return st;
  -    }
  -
  -    public Call getCall() throws WSIFException {
  -        Trc.entry(this);
  -     if ( call == null ) {
  -           Transport axistransport = getAxisTransport();
  -           java.net.URL url = getEndPoint();
  -           try {
  -              if (url != null) {
  -                 call = new Call(url);
  -                 if (axistransport != null) {
  -                    axistransport.setUrl(url.toString());
  -                 }
  -              } else
  -                 call = new Call( new org.apache.axis.client.Service() );
  -           } catch (JAXRPCException e) {
  -                     Trc.exception(e);
  -              throw new WSIFException(e.toString());
  -           }
  -     }
  -     call.setMaintainSession(true);
  -        Trc.exit(call);
  -        return call;
  -    }
  -
  -    public void setDefinition(Definition definition1) {
  -        Trc.entry(this, definition1);
  -        definition = definition1;
  -        Trc.exit();
  -    }
  -
  -    public void setDynamicWSIFOperation(
  -        String s,
  -        String s1,
  -        String s2,
  -        WSIFOperation_ApacheAxis wsifoperation_apacheaxis) {
  -        Trc.entry(this, s, s1, s2, wsifoperation_apacheaxis);
  -        operationInstances.put(getKey(s, s1, s2), wsifoperation_apacheaxis);
  -        Trc.exit();
  -    }
  -
  -    public WSIFOperation createOperation(String operationName)
  -        throws WSIFException {
  -        Trc.entry(this, operationName);
  -        WSIFOperation wo = createOperation(operationName, null, null);
  -        Trc.exit(wo);
  -        return wo;
  -    }
  -
  -    public WSIFOperation createOperation(
  -        String operationName,
  -        String inputName,
  -        String outputName)
  -        throws WSIFException {
  -        Trc.entry(this, operationName, inputName, outputName);
  -
  -        WSIFOperation_ApacheAxis op =
  -            getDynamicWSIFOperation(operationName, inputName, outputName);
  -        if (op == null) {
  -            throw new WSIFException(
  -                "Could not create operation: "
  -                    + operationName
  -                    + ":"
  -                    + inputName
  -                    + ":"
  -                    + outputName);
  -        }
  -        WSIFOperation wo = op.copy();
  -        Trc.exit(wo);
  -        return wo;
  -    }
  -
  -    public void setEndPoint(URL url1) {
  -        Trc.entry(this, url1);
  -        url = url1;
  -        Trc.exit();
  -    }
  -
  -    public void setPort(Port port1) {
  -        Trc.entry(this, port1);
  -        port = port1;
  -        Trc.exit();
  -    }
  -
  -    /**
  -     * Tests if this port supports asynchronous calls to operations.
  -     * 
  -     * @return true if the port is using a JMS transport, otherwise false
  -     */
  -    public boolean supportsAsync() {
  -        Trc.entry(this);
  -        if (st != null && JMS_TRANSPORT == transportcode) {
  -            Trc.exit(true);
  -            return true;
  -        } else {
  -            Trc.exit(false);
  -            return false;
  -        }
  -    }
  -
  -    /**
  -     * Closes the port. All methods are invalid after calling this method.
  -     */
  -    public void close() throws WSIFException {
  -        Trc.entry(this);
  -        if (st != null && st instanceof WSIFJmsTransport) {
  -            ((WSIFJmsTransport) st).close();
  -        }
  -        Trc.exit();
  -    }
  -
  -    public String deep() {
  -        String buff = "";
  -        try {
  -            buff = new String(super.toString() + ":\n");
  -            buff += "operationInstances:" + operationInstances;
  -            buff += " port:" + port;
  -            buff += " definition:" + definition;
  -            buff += " url:" + url;
  -            buff += " transportcode:" + transportcode;
  -            buff += " st:" + st;
  -            buff += " jmsAddressPropVals:" + jmsAddressPropVals;
  -        } catch (Exception e) {
  -            Trc.exceptionInTrace(e);
  -        }
  -        return buff;
  -    }
  +
  +             if (wsifOperation == null) {
  +                     // TODO I don't really understand what this is doing
  +                     // TODO can't I delete all this now???
  +                     BindingOperation bindingOperationModel =
  +                             port.getBinding().getBindingOperation(
  +                                     name,
  +                                     inputName,
  +                                     outputName);
  +                     if (bindingOperationModel != null) {
  +                             // Only one operation matched in binding so find it in 
instances
  +                             // from all the information that is available to us
  +                             Iterator i = operationInstances.keySet().iterator();
  +                             while (i.hasNext()) {
  +                                     String key = (String) i.next();
  +                                     if ((outputName != null && 
key.endsWith(outputName))
  +                                             || outputName == null) {
  +                                             String start =
  +                                                     (inputName == null)
  +                                                             ? name + ":"
  +                                                             : name + ":" + 
inputName;
  +                                             if (key.startsWith(start)) {
  +                                                     if (wsifOperation != null) {
  +                                                             // Duplicate operation 
found based on names!
  +                                                             wsifOperation = null;
  +                                                             break;
  +                                                     }
  +                                                     wsifOperation =
  +                                                             (
  +                                                                     
WSIFOperation_ApacheAxis) operationInstances
  +                                                                             .get(
  +                                                                     key);
  +                                             }
  +                                     }
  +                             }
  +                     }
  +
  +                     Binding binding = port.getBinding();
  +                     PortType portType = binding.getPortType();
  +                     Operation operation =
  +                             portType.getOperation(name, inputName, outputName);
  +                     if (operation == null) {
  +                             throw new WSIFException(
  +                                "no operation found named " + 
  +                                name + ", input:" + inputName + ", output:" + 
outputName );
  +                     }
  +                     String opName = operation.getName();
  +                     Input input = operation.getInput();
  +                     Output output = operation.getOutput();
  +                     wsifOperation =
  +                             new WSIFOperation_ApacheAxis(
  +                                     this,
  +                                     operation,
  +                                     wsifdynamictypemap);
  +                     operationInstances.put(
  +                             getKey(opName, inputName, outputName),
  +                             wsifOperation);
  +             }
  +
  +             Trc.exit(wsifOperation);
  +             return wsifOperation;
  +     }
  +
  +     /**
  +      * Returns the URL of the location attribute of the soap:address 
  +      * @return URL   the URL of the service location        
  +      */
  +     public URL getEndPoint() {
  +             Trc.entry(this);
  +             Trc.exit(endPointURL);
  +             return endPointURL;
  +     }
  +
  +     /**
  +      * Wrapper to enable WSIFOperation to use the same WSIFDefaultPort method
  +      * @see WSIFDefaultPort.getExtElem
  +      */
  +     public Object getExtElem(Object ctx, Class extType, List extElems)
  +             throws WSIFException {
  +             Trc.entry(this, ctx, extType, extElems);
  +             Object o = super.getExtElem(ctx, extType, extElems);
  +             Trc.exit(o);
  +             return o;
  +     }
  +
  +     /**
  +      * Wrapper to enable WSIFOperation to use the same WSIFDefaultPort method
  +      * @see WSIFDefaultPort.getExtElems
  +      */
  +     public List getExtElems(Object ctx, Class extType, List extElems)
  +             throws WSIFException {
  +             Trc.entry(this, ctx, extType, extElems);
  +             List l = super.getExtElems(ctx, extType, extElems);
  +             Trc.exit(l);
  +             return l;
  +     }
  +
  +     /**
  +      * Returns any JMS propertyValue elements in the jms:address element
  +      * @return List   a List of the jms:propertyValue elements 
  +      */
  +     public List getJmsAddressPropVals() {
  +             Trc.entry(this);
  +             Trc.exit(jmsAddressPropVals);
  +             return jmsAddressPropVals;
  +     }
  +
  +     /**
  +      * Returns the WSDL Port object this WSIFPort represents
  +      * @return Port   the WSDL4J Port object
  +      */
  +     public Port getPort() {
  +             Trc.entry(this);
  +             Trc.exit(port);
  +             return port;
  +     }
  +
  +     /**
  +      * Gets the soap:operation WSDL element for a BindingOperation
  +      * @return SOAPOperation   the soap:operation element
  +      */
  +     public SOAPOperation getSOAPOperation(BindingOperation bindingOp)
  +             throws WSIFException {
  +             Trc.entry(this, bindingOp);
  +             SOAPOperation soapOperation =
  +                     (SOAPOperation) getExtElem(bindingOp,
  +                             javax.wsdl.extensions.soap.SOAPOperation.class,
  +                             bindingOp.getExtensibilityElements());
  +             if (soapOperation == null)
  +                     throw new WSIFException(
  +                             "no soap:operation found in binding for: " + 
bindingOp);
  +             Trc.exit(soapOperation);
  +             return soapOperation;
  +     }
  +
  +     /**
  +      * Gets the AXIS Transport object being used by this WSIFPort 
  +      * @return Transport   the AXIS Transport object
  +      */
  +     public Transport getTransport() throws WSIFException {
  +             Trc.entry(this);
  +             if (transport == null) {
  +                     String s = soapBinding.getTransportURI();
  +                     if (HTTP_TRANSPORT_URI.equals(s)) {
  +                             transport = new HTTPTransport();
  +                     } else if (JMS_TRANSPORT_URI.equals(s)) {
  +                             WSIFJMSDestination jmsDestination =
  +                                     new WSIFJMSDestination(
  +                                             WSIFJMSFinder.newFinder(jmsAddress, 
port.getName()),
  +                                             jmsAddress.getJmsProvDestName(),
  +                                             WSIFProperties.getSyncTimeout());
  +                             transport = new WSIFJmsTransport(jmsDestination);
  +                     }
  +             }
  +             Trc.exit(transport);
  +             return transport;
  +     }
  +
  +     /**
  +      * Tests if an HTTP transport is being used
  +      * @return boolean   true if an HTTP transport is being used,
  +      *                    otherwise false
  +      */
  +     public boolean isTransportHTTP() {
  +             Trc.entry(this);
  +             String transportURI = soapBinding.getTransportURI();
  +             boolean httpTransport = HTTP_TRANSPORT_URI.equals(transportURI);
  +             Trc.exit(httpTransport);
  +             return httpTransport;
  +     }
  +
  +     /**
  +      * Tests if a JMS transport is being used
  +      * @return boolean   true if a JMS transport is being used,
  +      *                    otherwise false
  +      */
  +     public boolean isTransportJMS() {
  +             Trc.entry(this);
  +             String transportURI = soapBinding.getTransportURI();
  +             boolean jmsTransport = JMS_TRANSPORT_URI.equals(transportURI);
  +             Trc.exit(jmsTransport);
  +             return jmsTransport;
  +     }
  +
  +     /**
  +      * @deprecated should anyone be calling this? 
  +      */
  +     public void setDefinition(Definition definition1) {
  +             Trc.entry(this, definition1);
  +             definition = definition1;
  +             Trc.exit();
  +     }
  +
  +     /**
  +      * @deprecated should anyone be calling this? 
  +      */
  +     public void setDynamicWSIFOperation(
  +             String s,
  +             String s1,
  +             String s2,
  +             WSIFOperation_ApacheAxis wsifoperation_apacheaxis) {
  +             Trc.entry(this, s, s1, s2, wsifoperation_apacheaxis);
  +             operationInstances.put(getKey(s, s1, s2), wsifoperation_apacheaxis);
  +             Trc.exit();
  +     }
  +
  +     /**
  +      * @deprecated should anyone be calling this? 
  +      */
  +     public void setEndPoint(URL url1) {
  +             Trc.entry(this, url1);
  +             endPointURL = url1;
  +             Trc.exit();
  +     }
  +
  +     /**
  +      * @deprecated should anyone be calling this? 
  +      */
  +     public void setPort(Port port1) {
  +             Trc.entry(this, port1);
  +             port = port1;
  +             Trc.exit();
  +     }
  +
  +     /**
  +      * Tests if this port supports asynchronous calls to operations.
  +      * @return true if the port is using a JMS transport, otherwise false
  +      */
  +     public boolean supportsAsync() {
  +             Trc.entry(this);
  +             if (isTransportJMS()) {
  +                     Trc.exit(true);
  +                     return true;
  +             } else {
  +                     Trc.exit(false);
  +                     return false;
  +             }
  +     }
  +
  +     public String deep() {
  +             StringBuffer buff = new StringBuffer();
  +             try {
  +                     buff.append(new String(super.toString()));
  +                     buff.append(":\n");
  +                     buff.append(" port: ");
  +                     buff.append(port);
  +                     buff.append(" definition: ");
  +                     buff.append(definition);
  +                     buff.append(" soapbinding: ");
  +                     buff.append(soapBinding);
  +                     buff.append(" bindingStyle: ");
  +                     buff.append(bindingStyle);
  +                     buff.append(" soapAddress: ");
  +                     buff.append(soapAddress);
  +                     buff.append(" jmsAddress: ");
  +                     buff.append(jmsAddress);
  +                     buff.append(" service url: ");
  +                     buff.append(endPointURL);
  +                     buff.append(" jmsAddressPropVals: ");
  +                     buff.append(jmsAddressPropVals);
  +                     buff.append(" dynamicTypeMap: ");
  +                     buff.append(wsifdynamictypemap);
  +                     buff.append(" transport: ");
  +                     buff.append(transport);
  +                     buff.append(" call: ");
  +                     buff.append(call);
  +                     buff.append("operationInstances: ");
  +                     buff.append(operationInstances);
  +             } catch (Exception e) {
  +                     Trc.exceptionInTrace(e);
  +             }
  +             return buff.toString();
  +     }
  +
   }
  
  
  
  1.7       +140 -136  
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFDynamicProvider_ApacheAxis.java
  
  Index: WSIFDynamicProvider_ApacheAxis.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFDynamicProvider_ApacheAxis.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WSIFDynamicProvider_ApacheAxis.java       18 Sep 2002 15:38:20 -0000      1.6
  +++ WSIFDynamicProvider_ApacheAxis.java       2 Dec 2002 13:26:21 -0000       1.7
  @@ -59,9 +59,9 @@
   
   import java.security.AccessController;
   import java.security.PrivilegedAction;
  +import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  -import java.util.Vector;
   
   import javax.wsdl.Binding;
   import javax.wsdl.Definition;
  @@ -81,140 +81,144 @@
    * @author Ant Elder <[EMAIL PROTECTED]>
    * @author Jeremy Hughes <[EMAIL PROTECTED]>
    * @author Mark Whitlock <[EMAIL PROTECTED]>
  -*/
  + */
   public class WSIFDynamicProvider_ApacheAxis implements WSIFProvider {
  -    private static final String soap = "http://schemas.xmlsoap.org/wsdl/soap/";;
  -    private static final String jms = "http://schemas.xmlsoap.org/wsdl/jms/";;
  -    private static String[] bindings = new String[0];
  -    private static String[] addresses = new String[0];
  -    private static boolean setUpBindings = false;
  -    private static boolean setUpAddresses = false;
  -
  -    public WSIFDynamicProvider_ApacheAxis() {
  -        Trc.entry(this);
  -        if (!setUpBindings) {
  -            setUpBindingNamespaceURIs();
  -        }
  -        if (!setUpAddresses) {
  -            setUpAddressNamespaceURIs();
  -        }        
  -        WSIFServiceImpl.addExtensionRegistry(
  -            new org.apache.wsif.wsdl.extensions.jms.JMSExtensionRegistry());
  -        Trc.exit();
  -    }
  -
  -    public WSIFPort createDynamicWSIFPort(
  -        Definition definition,
  -        Service service,
  -        Port port,
  -        WSIFDynamicTypeMap wsifdynamictypemap)
  -        throws WSIFException {
  -        Trc.entry(this, definition, service, port, wsifdynamictypemap);
  -        Binding binding = port.getBinding();
  -        List list = binding.getExtensibilityElements();
  -        for (Iterator iterator = list.iterator(); iterator.hasNext();) {
  -            Object obj = iterator.next();
  -            if (obj instanceof SOAPBinding) {
  -                WSIFPort wp =
  -                    new WSIFPort_ApacheAxis(definition, service, port, 
wsifdynamictypemap);
  -                Trc.exit(wp);
  -                return wp;
  -            }
  -        }
  -
  -        Trc.exit(null);
  -        return null;
  -    }
  -
  -    /**
  -     * Returns the WSDL namespace URIs of any bindings this provider supports.
  -     * @return an array of all binding namespaces supported by this provider
  -     */
  -    public String[] getBindingNamespaceURIs() {
  -        Trc.entry(this);
  -        Trc.exit(bindings);
  -        return bindings;
  -    }
  -
  -    /**
  -     * Returns the WSDL namespace URIs of any port addresses this provider supports.
  -     * @return an array of all address namespaces supported by this provider
  -     */
  -    public String[] getAddressNamespaceURIs() {
  -        Trc.entry(this);
  -        Trc.exit(addresses);
  -        return addresses;
  -    }
  -
  -    private void setUpBindingNamespaceURIs() {
  -        // check if the axis classes are available, if not then we cannot
  -        // support soap bindings!        
  -        Class cls =
  -            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  -            public Object run() {
  -                try {
  -                    return Class.forName(
  -                        "org.apache.axis.AxisEngine",
  -                        true,
  -                        Thread.currentThread().getContextClassLoader());
  -                } catch (Throwable ignored) {
  -                     Trc.ignoredException(ignored);
  -                }
  -                return null;
  -            }
  -        });
  -        if (cls != null) {
  -            bindings = new String[] { soap };
  -        }
  -        setUpBindings = true;
  -    }
  -
  -    private void setUpAddressNamespaceURIs() {
  -        Vector v = new Vector();
  -        // check if the jms classes are available, if not then we cannot
  -        // support jms addresses!        
  -        Class cls =
  -            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  -            public Object run() {
  -                try {
  -                    return Class.forName(
  -                        "javax.jms.Queue",
  -                        true,
  -                        Thread.currentThread().getContextClassLoader());
  -                } catch (Throwable ignored) {
  -                             Trc.ignoredException(ignored);
  -                }
  -                return null;
  -            }
  -        });
  -        if (cls != null) {
  -             v.add(jms);
  -        }
  -                        
  -        // check if the axis classes are available, if not then we cannot
  -        // support soap addresses!         
  -        Class cls2 =
  -            (Class) AccessController.doPrivileged(new PrivilegedAction() {
  -            public Object run() {
  -                try {
  -                    return Class.forName(
  -                        "org.apache.axis.AxisEngine",
  -                        true,
  -                        Thread.currentThread().getContextClassLoader());
  -                } catch (Throwable ignored) {
  -                     Trc.ignoredException(ignored);
  -                }
  -                return null;
  -            }
  -        });
  -        if (cls2 != null) {
  -             v.add(soap);
  -        }         
  -        addresses = null;
  -        addresses = new String[v.size()];
  -        for (int i = 0; i < v.size(); i++) {
  -            addresses[i] = (String) v.elementAt(i);
  -        }
  -        setUpAddresses = true;
  -    }
  +
  +     private static final boolean axisAvailable = isAXISAvailable();
  +     private static final boolean jmsAvailable = isJMSAvailable();
  +     private static final String[] bindings = setUpBindingNamespaceURIs();
  +     private static final String[] addresses = setUpAddressNamespaceURIs();
  +
  +     /**
  +      * Construct a new AXIS provider 
  +      */
  +     public WSIFDynamicProvider_ApacheAxis() {
  +             Trc.entry(this);
  +             if (axisAvailable && jmsAvailable) {
  +                     WSIFServiceImpl.addExtensionRegistry(
  +                             new 
org.apache.wsif.wsdl.extensions.jms.JMSExtensionRegistry());
  +             }
  +             Trc.exit();
  +     }
  +
  +     /**
  +      * Create a new AXIS WSIFPort
  +      * @see WSIFProvider.createDynamicWSIFPort
  +      */
  +     public WSIFPort createDynamicWSIFPort(
  +             Definition definition,
  +             Service service,
  +             Port port,
  +             WSIFDynamicTypeMap wsifdynamictypemap)
  +             throws WSIFException {
  +             Trc.entry(this, definition, service, port, wsifdynamictypemap);
  +
  +             Binding binding = port.getBinding();
  +             List list = binding.getExtensibilityElements();
  +
  +             WSIFPort wp = null;
  +             for (Iterator i = list.iterator();(i.hasNext() && wp == null);) {
  +                     Object o = i.next();
  +                     if (o instanceof SOAPBinding) {
  +                             wp = new WSIFPort_ApacheAxis(
  +                                             definition,
  +                                             port,
  +                                             (SOAPBinding) o,
  +                                             wsifdynamictypemap);
  +                     }
  +             }
  +
  +             Trc.exit(wp);
  +             return wp;
  +     }
  +
  +     /**
  +      * Returns the WSDL namespace URIs of any bindings this provider supports.
  +      * @return an array of all binding namespaces supported by this provider
  +      */
  +     public String[] getBindingNamespaceURIs() {
  +             Trc.entry(this);
  +             Trc.exit(bindings);
  +             return bindings;
  +     }
  +
  +     /**
  +      * Returns the WSDL namespace URIs of any port addresses this provider 
supports.
  +      * @return an array of all address namespaces supported by this provider
  +      */
  +     public String[] getAddressNamespaceURIs() {
  +             Trc.entry(this);
  +             Trc.exit(addresses);
  +             return addresses;
  +     }
  +
  +     /**
  +      * Sets up the binding namespace URIs this provider supports.
  +      */
  +     private static String[] setUpBindingNamespaceURIs() {
  +             String[] bindings;
  +             if (axisAvailable) {
  +                     bindings =
  +                             new String[] { 
WSIFAXISConstants.SOAP_BINDING_NAMESPACE };
  +             } else {
  +                     bindings = new String[0];
  +             }
  +             Trc.event("available binding namespace URIs: ", bindings);
  +             return bindings;
  +     }
  +
  +     /**
  +      * Sets up the address namespace URIs this provider supports.
  +      */
  +     private static String[] setUpAddressNamespaceURIs() {
  +             ArrayList l = new ArrayList();
  +             if (isAXISAvailable()) {
  +                     l.add(WSIFAXISConstants.SOAP_BINDING_NAMESPACE);
  +             }
  +             if (jmsAvailable) {
  +                     l.add(WSIFAXISConstants.JMS_TRANSPORT_URI);
  +             }
  +             String[] addresses = new String[l.size()];
  +             for (int i = 0; i < l.size(); i++) {
  +                     addresses[i] = (String) l.get(i);
  +             }
  +             Trc.event("available address namespace URIs: ", addresses);
  +             return addresses;
  +     }
  +
  +     /**
  +      * Checks if the axis.jar is available in the Java CLASSPATH
  +      */
  +     private static boolean isAXISAvailable() {
  +             return isClassAvailable(WSIFAXISConstants.CLASS_IN_AXIS_JAR);
  +     }
  +
  +     /**
  +      * Checks if the JMS API jar is available in the Java CLASSPATH
  +      */
  +     private static boolean isJMSAvailable() {
  +             return isClassAvailable(WSIFAXISConstants.CLASS_IN_JMS_JAR);
  +     }
  +
  +     /**
  +      * Checks if a class is available in the Java CLASSPATH
  +      */
  +     private static boolean isClassAvailable(final String className) {
  +             Class c =
  +                     (Class) AccessController.doPrivileged(new PrivilegedAction() {
  +                     public Object run() {
  +                             try {
  +                                     return Class.forName(
  +                                             className,
  +                                             true,
  +                                             
Thread.currentThread().getContextClassLoader());
  +                             } catch (Throwable ignored) {
  +                                     Trc.ignoredException(ignored);
  +                             }
  +                             return null;
  +                     }
  +             });
  +             return c != null;
  +     }
  +
   }
  
  
  
  1.5       +13 -5     
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsTransport.java
  
  Index: WSIFJmsTransport.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsTransport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSIFJmsTransport.java     15 Nov 2002 09:31:57 -0000      1.4
  +++ WSIFJmsTransport.java     2 Dec 2002 13:26:21 -0000       1.5
  @@ -84,6 +84,13 @@
       public static final String SYNC_TIMEOUT = "syncTimeout";
       public static final String ASYNC_TIMEOUT = "asyncTimeout";
   
  +    public WSIFJmsTransport(WSIFJMSDestination destination) throws WSIFException {
  +     if (destination == null) {
  +             throw new WSIFException("destination is null");
  +     }
  +     this.destination = destination;
  +    }
  +
       public void setDestination(WSIFJMSDestination destination) {
           Trc.entry(this, destination);
           this.destination = destination;
  @@ -163,10 +170,9 @@
           Trc.exit();
       }
   
  -    public WSIFJmsTransport copy() {
  +    public WSIFJmsTransport copy() throws WSIFException {
           Trc.entry(this);
  -        WSIFJmsTransport t = new WSIFJmsTransport();
  -        t.setDestination(destination);
  +        WSIFJmsTransport t = new WSIFJmsTransport(destination);
           t.setAsyncOperation(asyncOperation);
           t.setWsifOperation(wsifOperation);
           t.setSyncTimeout(syncTimeout);
  @@ -178,9 +184,11 @@
   
       public void close() throws WSIFException {
           Trc.entry(this);
  -     if (destination != null) {
  -             destination.close();
  +     if (destination == null) {
  +             throw new WSIFException("already closed");
        }
  +             destination.close();
  +             destination = null;
           Trc.exit();
       }
       
  
  
  
  1.1                  
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFAXISConstants.java
  
  Index: WSIFAXISConstants.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.wsif.providers.soap.apacheaxis;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  
  /**
   * Various constants used by the WSIF AXIS provider classes
   * 
   * @author Ant Elder <[EMAIL PROTECTED]>
   */
  public class WSIFAXISConstants {
  
        public static final String SOAP_BINDING_NAMESPACE =
                "http://schemas.xmlsoap.org/wsdl/soap/";;
  
        public static final String HTTP_TRANSPORT_URI =
                "http://schemas.xmlsoap.org/soap/http";;
  
        public static final String JMS_TRANSPORT_URI =
                "http://schemas.xmlsoap.org/soap/jms";;
  
        public static final ArrayList VALID_TRANSPORTS =
                new ArrayList(
                        Arrays.asList(
                                new String[] { HTTP_TRANSPORT_URI, JMS_TRANSPORT_URI 
}));
  
        public static final String CLASS_IN_AXIS_JAR = "org.apache.axis.AxisEngine";
  
        public static final String CLASS_IN_JMS_JAR = "javax.jms.Queue";
  
        public static final String DEFAULT_SOAP_ENCODING_URI =
                "http://schemas.xmlsoap.org/soap/encoding/";;
  
        public static final String STYLE_RPC = "rpc";
        public static final String STYLE_DOCUMENT = "document";
        public static final ArrayList VALID_STYLES =
                new ArrayList(
                        Arrays.asList(new String[] { STYLE_RPC, STYLE_DOCUMENT }));
  
        public static final String USE_ENCODED = "encoded";
        public static final String USE_LITERAL = "literal";
        public static final ArrayList VALID_USES =
                new ArrayList(
                        Arrays.asList(new String[] { USE_ENCODED, USE_LITERAL }));
  
        public static final String AXIS_STYLE_MESSAGE = "message";
        public static final String AXIS_STYLE_WRAPPED = "wrapped";
  
  }
  
  
  


Reply via email to