Axis2
  1. Axis2
  2. AXIS2-4264

Empty action not applied in CommonsHTTPTransportSender

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3, 1.4, 1.4.1, 1.5
    • Fix Version/s: 1.6.0
    • Component/s: transports
    • Labels:
      None

      Description

      Hello there,

      I'm invoking a service using a ServiceClient, the wsdl operation declares an empty soapAction.
      However the soapActiuon actually sent is "urn:anonOutInOp" which the server refuses. This action is the action the anonymous operation "urn:anonOutInOp" and is set by the ServiceClient.

      Later when CommonsHTTPTransportSender#findSOAPAction [1] is invoked, if the action of the MessageContext is null or empty, the operation action is used. The empty case seems like a bug, because this is the action set in the wsdl and it is not applied.
      This opinion is strengthened by the fact that other senders do not have this behavior.

      The right behavior would be:
      if null ; use the operation action as a default
      if empty ; send an empty soapAction

      Could you confirm please?

      Alexis

      [1] http://is.gd/m0Mt

        Activity

        Hide
        Victor added a comment -

        I could, but first I would prefer to get feedback about what should be expected, because I'm not an expert in SOAP and I'm not clear when it is then needed to use AxisOperation for the SoapAction… Actually I'm not even clear if the WSDL's SoapAction is available from code through the AxisOperation or through the MessageContext (i.e. the Option object)… I'm currently taking over on big base of code using Axis, so I'm not even sure if it was coded correctly with respect to how Axis is meant to be used, but I can put a bit of my time to help fixing this issue.

        In terms of requirements:
        To me, if there is no soapAction defined in the WSDL or if there is an empty value is the same thing: a empty soap action should be sent.
        For SOAP 1.2, it is the specs that says so.
        For SOAP 1.1, no soap action is considered invalid WSDL: I would say it's better to follow SOAP 1.2 spec on that, but maybe that's where you thought we should use the AxisOperation as the soap action?

        So to fixes this, I'm not sure where it should really happen… but if it has to be in CommonsHTTPTransportSender and these requirements I wrote are correct, I can give it a shot.

        Show
        Victor added a comment - I could, but first I would prefer to get feedback about what should be expected, because I'm not an expert in SOAP and I'm not clear when it is then needed to use AxisOperation for the SoapAction… Actually I'm not even clear if the WSDL's SoapAction is available from code through the AxisOperation or through the MessageContext (i.e. the Option object)… I'm currently taking over on big base of code using Axis, so I'm not even sure if it was coded correctly with respect to how Axis is meant to be used, but I can put a bit of my time to help fixing this issue. In terms of requirements: To me, if there is no soapAction defined in the WSDL or if there is an empty value is the same thing: a empty soap action should be sent. For SOAP 1.2, it is the specs that says so. For SOAP 1.1, no soap action is considered invalid WSDL: I would say it's better to follow SOAP 1.2 spec on that, but maybe that's where you thought we should use the AxisOperation as the soap action? So to fixes this, I'm not sure where it should really happen… but if it has to be in CommonsHTTPTransportSender and these requirements I wrote are correct, I can give it a shot.
        Hide
        Andreas Veithen added a comment -

        Can you provide a patch and a unit test?

        Show
        Andreas Veithen added a comment - Can you provide a patch and a unit test?
        Hide
        Victor added a comment -

        And it is the same for a null soapAction with SOAP1.2, the corresponding default value is empty soap action as Alexis highlighted in one of its comments…

        Show
        Victor added a comment - And it is the same for a null soapAction with SOAP1.2, the corresponding default value is empty soap action as Alexis highlighted in one of its comments…
        Hide
        Victor added a comment -

        Hi, is this really fixed?

        I still have problems after moving to Axis2 1.6.3.

        If I have an empty (not null) soapAction in the MessageContext, then Axis2 doesn't want to use it as is and insist on using the AxisOperation name instead.

        I think the problem is line 469 of CommonsHTTPTransportSender, just after querying the MessageContext for the soapAction, the test consider an empty string as not valid.

        Am I mistaken? Thanks!

        Show
        Victor added a comment - Hi, is this really fixed? I still have problems after moving to Axis2 1.6.3. If I have an empty (not null) soapAction in the MessageContext, then Axis2 doesn't want to use it as is and insist on using the AxisOperation name instead. I think the problem is line 469 of CommonsHTTPTransportSender, just after querying the MessageContext for the soapAction, the test consider an empty string as not valid. Am I mistaken? Thanks!
        Hide
        Rich Scheuerle added a comment -

        Reopened....Note that the code supplied by Dims checks for the same constructed name 3 times instead of checking for the 3 constructed names.

        Show
        Rich Scheuerle added a comment - Reopened....Note that the code supplied by Dims checks for the same constructed name 3 times instead of checking for the 3 constructed names.
        Hide
        Rich Scheuerle added a comment -

        Committed revision 785637

        Show
        Rich Scheuerle added a comment - Committed revision 785637
        Hide
        Davanum Srinivas added a comment -

        Props to Xin Huang for finding the JIRA defects and Rich Scheuerle for suggesting the fix.

        thanks,
        dims

        Show
        Davanum Srinivas added a comment - Props to Xin Huang for finding the JIRA defects and Rich Scheuerle for suggesting the fix. thanks, dims
        Hide
        Davanum Srinivas added a comment -

        Alexis,

        we think there may be cases where AxisOperation may be the correct one to use. Can you please try this patch? You may have to apply the patch by hand as there are differences between current axis2 version and the one that i am using.

        thanks,
        dims

        Index: src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
        ===================================================================
        — src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (revision 6604)
        +++ src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (working copy)
        @@ -22,6 +22,7 @@
        import org.apache.axiom.om.OMOutputFormat;
        import org.apache.axis2.AxisFault;
        import org.apache.axis2.Constants;
        +import org.apache.axis2.client.ServiceClient;
        import org.apache.axis2.addressing.EndpointReference;
        import org.apache.axis2.context.ConfigurationContext;
        import org.apache.axis2.context.MessageContext;
        @@ -399,12 +400,25 @@
        if ((soapActionString == null) || (soapActionString.length() == 0)) {
        // now let's try to get WSA action
        soapActionString = messageContext.getWSAAction();
        + if (log.isDebugEnabled())

        { + log.debug("SOAP Action from getWSAAction was : " + soapActionString); + }

        if (messageContext.getAxisOperation() != null
        && ((soapActionString == null) || (soapActionString
        .length() == 0))) {
        // last option is to get it from the axis operation

        • soapActionString = messageContext.getAxisOperation()
          + String axisOpSOAPAction = messageContext.getAxisOperation()
          .getSoapAction();
          + log.debug("SOAP Action from AxisOperation was : " + axisOpSOAPAction);
          + if (ServiceClient.ANON_OUT_ONLY_OP.equals(axisOpSOAPAction)
          + || (ServiceClient.ANON_OUT_ONLY_OP.equals(axisOpSOAPAction))
          + || (ServiceClient.ANON_OUT_ONLY_OP.equals(axisOpSOAPAction)))
          Unknown macro: {+ if (log.isDebugEnabled()) { + log.debug("Will not override SOAP Action as " + axisOpSOAPAction + " in AxisOperation was auto-generated"); + }+ }

          else

          { + soapActionString = axisOpSOAPAction; + }

          }
          }
          }

        Show
        Davanum Srinivas added a comment - Alexis, we think there may be cases where AxisOperation may be the correct one to use. Can you please try this patch? You may have to apply the patch by hand as there are differences between current axis2 version and the one that i am using. thanks, dims Index: src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java =================================================================== — src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (revision 6604) +++ src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (working copy) @@ -22,6 +22,7 @@ import org.apache.axiom.om.OMOutputFormat; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; +import org.apache.axis2.client.ServiceClient; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.MessageContext; @@ -399,12 +400,25 @@ if ((soapActionString == null) || (soapActionString.length() == 0)) { // now let's try to get WSA action soapActionString = messageContext.getWSAAction(); + if (log.isDebugEnabled()) { + log.debug("SOAP Action from getWSAAction was : " + soapActionString); + } if (messageContext.getAxisOperation() != null && ((soapActionString == null) || (soapActionString .length() == 0))) { // last option is to get it from the axis operation soapActionString = messageContext.getAxisOperation() + String axisOpSOAPAction = messageContext.getAxisOperation() .getSoapAction(); + log.debug("SOAP Action from AxisOperation was : " + axisOpSOAPAction); + if (ServiceClient.ANON_OUT_ONLY_OP.equals(axisOpSOAPAction) + || (ServiceClient.ANON_OUT_ONLY_OP.equals(axisOpSOAPAction)) + || (ServiceClient.ANON_OUT_ONLY_OP.equals(axisOpSOAPAction))) Unknown macro: {+ if (log.isDebugEnabled()) { + log.debug("Will not override SOAP Action as " + axisOpSOAPAction + " in AxisOperation was auto-generated"); + }+ } else { + soapActionString = axisOpSOAPAction; + } } } }
        Hide
        Alexis Midon added a comment -

        no, I'm not making changes to spam the dev list

        Show
        Alexis Midon added a comment - no, I'm not making changes to spam the dev list
        Hide
        Alexis Midon added a comment -

        Actually the soapAction attribute is not mandatory, and if not specified the right default is an empty string.
        I updated the patch accordingly.

        http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#SOAPAction_HTTP_Header
        http://www.w3.org/TR/wsdl#_soap:operation

        Show
        Alexis Midon added a comment - Actually the soapAction attribute is not mandatory, and if not specified the right default is an empty string. I updated the patch accordingly. http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#SOAPAction_HTTP_Header http://www.w3.org/TR/wsdl#_soap:operation
        Hide
        Alexis Midon added a comment -

        I attached a patch implementing the logic described above.
        This patch could be applied to 1.3, 1.4.1 or 1.5.

        Show
        Alexis Midon added a comment - I attached a patch implementing the logic described above. This patch could be applied to 1.3, 1.4.1 or 1.5.

          People

          • Assignee:
            Rich Scheuerle
            Reporter:
            Alexis Midon
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development