You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-dev@ws.apache.org by as...@apache.org on 2005/08/10 13:45:18 UTC

cvs commit: ws-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis WSIFOperation_ApacheAxis.java

aslom       2005/08/10 04:45:18

  Modified:    java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFOperation_ApacheAxis.java
  Log:
  applied patch for http://issues.apache.org/jira/browse/WSIF-73?page=all
  "WSIF provider for apacheaxis does not support SOAP Faults when operationStyle==WSIFAXISConstants.AXIS_STYLE_MESSAGE"
  provided by Rhett DeWall (thanks!)
  
  Revision  Changes    Path
  1.92      +52 -8     ws-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
  
  Index: WSIFOperation_ApacheAxis.java
  ===================================================================
  RCS file: /home/cvs/ws-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- WSIFOperation_ApacheAxis.java	28 Nov 2004 03:00:05 -0000	1.91
  +++ WSIFOperation_ApacheAxis.java	10 Aug 2005 11:45:17 -0000	1.92
  @@ -1227,10 +1227,37 @@
           
           if (resp instanceof AxisFault) {
               respOK = false;
  -            if (faultMsg != null) {
  +            if (faultMsg != null)
  +            {
  +                /* faultSupport -- Rewrite.
                   AxisFault f = (AxisFault) resp;
                   faultMsg.setName(WSIFConstants.SOAP_FAULT_MSG_NAME);
                   faultMsg.setObjectPart(WSIFConstants.SOAP_FAULT_OBJECT, f);
  +                */
  +                AxisFault f = (AxisFault) resp;
  +                org.w3c.dom.Element faultElement = f.getFaultDetails()[0];
  +                String nsURI = faultElement.getNamespaceURI();
  +                String localName = faultElement.getLocalName();
  +                QName faultQName = new QName( nsURI, localName );
  +                
  +                // Find the WSDL Fault information for this portTypeOperation.
  +                Map faults = portTypeOperation.getFaults();
  +                Iterator iter = faults.values().iterator();
  +                while(iter.hasNext())
  +                {
  +                    javax.wsdl.Fault opFault = (javax.wsdl.Fault)iter.next();
  +                    // Assuming that there is only one part, fetch it.
  +                    javax.wsdl.Message wsdlFaultMsg = opFault.getMessage();
  +                    Map parts = wsdlFaultMsg.getParts();
  +                    Part wsdlFaultPart = (Part)parts.values().iterator().next();
  +                    if( wsdlFaultPart.getElementName().equals(faultQName) )
  +                    {
  +                        faultMsg.setName( wsdlFaultMsg.getQName().getLocalPart() );
  +                        faultMsg.setObjectPart( wsdlFaultPart.getName(), faultElement );
  +                        faultMsg.setMessageDefinition(wsdlFaultMsg);
  +                        break;
  +                    }
  +                }
               }
           } else {
               respOK = true;
  @@ -1333,6 +1360,7 @@
           
           //TODO type checking against the WSDL part type
           msg.setObjectPart(name, value);
  +
           
           Trc.exit();
       }
  @@ -1765,7 +1793,7 @@
           WSIFMessage faultMsg)
           throws WSIFException {
           
  -        boolean workedOK = false;
  +        boolean workedOK = true;  // faultSupport:  default to true instead of false.
           
           List attachments = addReferencedAttachments(inMsg, call);
           addUnreferencedAttachments(call);
  @@ -1795,17 +1823,32 @@
           Object axisResponse; // the response should be a Vector of RPCElement objects
           try {
               axisResponse = call.invoke(axisInputs);
  +        /* faultSupport -- Rewrote catch block.
           } catch (RemoteException ex) {
               throw new WSIFException(
                   "exception on AXIS invoke: " + ex.getLocalizedMessage(),
                   ex);
           }
  +        */
  +        } catch (RemoteException e) {
  +            Trc.exception(e);
  +            axisResponse = e;
  +            workedOK = false;
  +        }
           Trc.event(this, "Returned from AXIS invoke, response: ", axisResponse);
           
  -        setOutputMessageValues(axisResponse, outMsg);
  -        setResponseUnreferencedAttachments(call, outMsg);
  -        
  -        workedOK = true;
  +        // faultSupport -- Added if condition.
  +        if( workedOK )
  +        {
  +            setOutputMessageValues(axisResponse, outMsg);
  +            setResponseUnreferencedAttachments(call, outMsg);
  +        }
  +        else
  +        {
  +            // faultSupport -- Replaced assignment with call to buildResponseMessages
  +            //workedOK = true;
  +            workedOK = buildResponseMessages(axisResponse, outMsg, faultMsg);
  +        }
           return workedOK;
       }
       
  @@ -2097,8 +2140,8 @@
               Object serializer = tm.getSerializer();
               Object deserializer = tm.getDeserializer();
               
  -            if ( (javaType == null) || (javaType.isAssignableFrom(clazz))
  -                    && ( (elementType == null) || (elementType.equals(xmlType)) ) ){
  +            if ( (javaType != null) && (javaType.isAssignableFrom(clazz))
  +                    && ( (elementType != null) && (elementType.equals(xmlType)) ) ){
                   if ((serializer == null || serializer instanceof SerializerFactory)
                           && (deserializer == null || deserializer instanceof DeserializerFactory)
                           && (serializer != null || deserializer != null)) {
  @@ -2944,3 +2987,4 @@
           return buff.toString();
       }
   }
  +