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 to...@apache.org on 2004/11/12 00:13:39 UTC

cvs commit: ws-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java Types.java

tomj        2004/11/11 15:13:39

  Modified:    java/src/org/apache/axis/encoding
                        DefaultSOAPEncodingTypeMappingImpl.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
                        Types.java
  Log:
  Fix bug 1646: WSDL for byte[] in a wrapped/doc/lit service was a xsd:byte
  array instead of a xsd:Base64Binary element per JAX-RPC.
  
  Special case the byte array in the emitting of wrapped parameters and make
  sure the type mapping is used.
  
  Plus, do some cleanup (comments, unneed initialization) in Emitter and
  DefaultSOAPEncodingTypeMapping.
  
  Revision  Changes    Path
  1.6       +3 -3      ws-axis/java/src/org/apache/axis/encoding/DefaultSOAPEncodingTypeMappingImpl.java
  
  Index: DefaultSOAPEncodingTypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/DefaultSOAPEncodingTypeMappingImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultSOAPEncodingTypeMappingImpl.java	29 Oct 2004 20:25:25 -0000	1.5
  +++ DefaultSOAPEncodingTypeMappingImpl.java	11 Nov 2004 23:13:39 -0000	1.6
  @@ -21,11 +21,11 @@
   import org.apache.axis.encoding.ser.Base64DeserializerFactory;
   
   /**
  - * @author Rich Scheuerle (scheu@us.ibm.com)
  - * 
  - * This is the implementation of the axis Default JAX-RPC SOAP 1.2 TypeMapping
  + *
  + * This is the implementation of the axis Default JAX-RPC SOAP Encoding TypeMapping
    * See DefaultTypeMapping for more information.
    * 
  + * @author Rich Scheuerle (scheu@us.ibm.com)
    */
   public class DefaultSOAPEncodingTypeMappingImpl extends DefaultTypeMappingImpl {
       
  
  
  
  1.132     +7 -9      ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.131
  retrieving revision 1.132
  diff -u -r1.131 -r1.132
  --- Emitter.java	27 Oct 2004 19:56:06 -0000	1.131
  +++ Emitter.java	11 Nov 2004 23:13:39 -0000	1.132
  @@ -316,11 +316,12 @@
               throws IOException, WSDLException, SAXException,
               ParserConfigurationException {
   
  -        Document doc = null;
  -        Definition def = null;
  +        Document doc;
  +        Definition def;
   
           switch (mode) {
   
  +            default:
               case MODE_ALL:
                   def = getWSDL();
   
  @@ -1230,8 +1231,7 @@
           // soapAction to the name of the operation. If NONE,
           // force soapAction to "".
           // Otherwise use the information in the operationDesc.
  -        String soapAction = "";
  -
  +        String soapAction;
           if (getSoapAction().equalsIgnoreCase("OPERATION")) {
               soapAction = oper.getName();
           } else if (getSoapAction().equalsIgnoreCase("NONE")) {
  @@ -1252,8 +1252,7 @@
           bindingOper.addExtensibilityElement(soapOper);
   
           // Add soap:body element to the binding <input> element
  -        ExtensibilityElement inputBody = null;
  -        inputBody = writeSOAPBody(desc.getElementQName());
  +        ExtensibilityElement inputBody = writeSOAPBody(desc.getElementQName());
           bindingInput.addExtensibilityElement(inputBody);
   
           // add soap:headers, if any, to binding <input> element
  @@ -1261,8 +1260,7 @@
   
           // Add soap:body element to the binding <output> element
           if (bindingOutput != null) {
  -            ExtensibilityElement outputBody = null;
  -            outputBody = writeSOAPBody(desc.getReturnQName());
  +            ExtensibilityElement outputBody = writeSOAPBody(desc.getReturnQName());
               bindingOutput.addExtensibilityElement(outputBody);
               bindingOper.setBindingOutput(bindingOutput);
   
  @@ -1619,8 +1617,8 @@
           QName qname = request
                   ? getRequestQName(oper)
                   : getResponseQName(oper);
  -        boolean hasParams = false;
   
  +        boolean hasParams;
           if (request) {
               hasParams = (oper.getNumInParams() > 0);
           } else {
  
  
  
  1.101     +14 -11    ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- Types.java	27 Oct 2004 04:25:59 -0000	1.100
  +++ Types.java	11 Nov 2004 23:13:39 -0000	1.101
  @@ -595,15 +595,18 @@
               return;
           }
   
  -        if (javaType.isArray()) {
  +        // JAX-RPC 1.1 says that byte[] should always be a Base64Binary
  +        // This (rather strange) hack will ensure that we don't map it
  +        // in to an maxoccurs=unbounded array.
  +        if (javaType.isArray() && !javaType.equals(byte[].class)) {
               type = writeTypeForPart(javaType.getComponentType(), null);
           } else {
               type = writeTypeForPart(javaType, type);
           }
   
           if (type == null) {
  -
  -            // throw an Exception!!
  +            // TODO: throw an Exception!!
  +            return;
           }
   
           Element childElem;
  @@ -624,7 +627,10 @@
   
               childElem.setAttribute("type", prefixedName);
   
  -            if (javaType.isArray()) {
  +            // JAX-RPC 1.1 says that byte[] should always be a Base64Binary
  +            // This (rather strange) hack will ensure that we don't map it
  +            // in to an maxoccurs=unbounded array.
  +            if (javaType.isArray() && !javaType.equals(byte[].class)) {
                   childElem.setAttribute("maxOccurs", "unbounded");
               }
           }
  @@ -1003,7 +1009,7 @@
        */
       public Element createArrayElement(String componentTypeName) {
   
  -        SOAPConstants constants = null;
  +        SOAPConstants constants;
           MessageContext mc = MessageContext.getCurrentContext();
           if(mc==null||mc.getSOAPConstants()==null){
               constants = SOAPConstants.SOAP11_CONSTANTS;    
  @@ -1756,9 +1762,7 @@
           }
   
           // look up the serializer in the TypeMappingRegistry
  -        Serializer ser = null;
  -        SerializerFactory factory = null;
  -
  +        SerializerFactory factory;
           if (tm != null) {
               factory = (SerializerFactory) tm.getSerializer(type, qName);
           } else {
  @@ -1777,9 +1781,8 @@
               }
           }
   
  -        if (factory != null) {
  -            ser = (Serializer) factory.getSerializerAs(Constants.AXIS_SAX);
  -        }
  +        // factory is not null
  +        Serializer ser = (Serializer) factory.getSerializerAs(Constants.AXIS_SAX);
   
           // if we can't get a serializer, that is bad.
           if (ser == null) {