axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alastair FETTES" <afet...@mdacorporation.com>
Subject [Axis2] Changes to WSDL2Java generated MessageReceiverInOut class
Date Thu, 03 Jan 2008 19:14:13 GMT
Apache Axis2 Team:

During our work with Apache Axis2 version 1.3 we have run into a
deficiency in the generated output from WSDL2Java in the form of the
MessageReceiverInOut class.  The problem lies in the order of
operations.

In the generated MessageReceiverInOut.java class, the out message
context does not have a valid SOAP envelope when the message handler in
the application supplied skeleton interface is called. Therefore, the
message handler cannot populate the contents of the out message SOAP
header. To solve the problem the out message SOAP envelope must be
created prior to calling the skeleton interface message handler.

Current implementation:

<snippet>
if((op.getName() != null)
    && ((methodName =
        org.apache.axis2.util.JavaUtils.xmlNameToJava(op.getName()
            .getLocalPart())) != null))
{
    if("MessageName".equals(methodName))
    {
        com.foo.messages.MessageNameResponseDocument
messageNameResponse170 =
            null;
        com.foo.messages.MessageNameRequestDocument wrappedParam =
            (com.foo.messages.MessageNameRequestDocument) fromOM(
                msgContext.getEnvelope().getBody()
                    .getFirstElement(),
                com.foo.messages.MessageNameRequestDocument.class,
                getEnvelopeNamespaces(msgContext.getEnvelope()));

        messageNameResponse170 = skel.MessageName(wrappedParam);

        envelope = toEnvelope(getSOAPFactory(msgContext),
                messageNameResponse170, false);
    }
    else
    {
        throw new java.lang.RuntimeException("method not found");
    }

    newMsgContext.setEnvelope(envelope);
}
</snippet>

Possible solution:

<snippet>
if((op.getName() != null)
    && ((methodName =
        org.apache.axis2.util.JavaUtils.xmlNameToJava(op.getName()
            .getLocalPart())) != null))
{
    if("MessageName".equals(methodName))
    {
        com.foo.messages.MessageNameResponseDocument
messageNameResponse170 =
            null;
        com.foo.messages.MessageNameRequestDocument wrappedParam =
            (com.foo.messages.MessageNameRequestDocument) fromOM(
                msgContext.getEnvelope().getBody()
                    .getFirstElement(),
                com.foo.messages.MessageNameRequestDocument.class,
                getEnvelopeNamespaces(msgContext.getEnvelope()));

        /*
         * Changes begin here
         */

        // Create the envelope and associate it with the message context
        // BEFORE the operation call
        envelope = getSOAPFactory(msgContext).getDefaultEnvelope();
        newMsgContext.setEnvelope(envelope);

        // operation call as normal
        messageNameResponse170 = skel.MessageName(wrappedParam);

        // 
        if (messageNameResponse170 != null)
        {
            envelope.getBody().addChild(toOM(messageNameResponse170,
false));
        }

        /*
         * Changes end here
         */
    }
    else
    {
        throw new java.lang.RuntimeException("method not found");
    }

    newMsgContext.setEnvelope(envelope);
}
</snippet>

The solution splits the functionality of the toEnvelope function into
two separate calls on either side of the operation call.  This allows
the operation to have access to the envelope and thus add custom SOAP
headers as appropriate.

Once again, thanks very much for your time and efforts on this project.

Sincerely,

Alastair Fettes

This e-mail and any attachments are intended solely for the use of the
intended recipient(s) and may contain legally privileged, proprietary
and/or confidential information.  Any use, disclosure, dissemination,
distribution or copying of this e-mail and any attachments for any
purposes that have not been specifically authorized by the sender is
strictly prohibited.  If you are not the intended recipient, please
immediately notify the sender by reply e-mail and permanently delete all
copies and attachments.

The entire content of this e-mail is for "information purposes" only and
should not be relied upon by the recipient in any way unless otherwise
confirmed in writing by way of letter or facsimile. 


Mime
View raw message