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 "Jian.Wu" <he...@gmail.com> on 2006/08/11 20:32:45 UTC

[Axis2]saaj.SOAPConnectionImpl does not handle MimeHeaders (SOAPAction)

Hi, 

I looked into org.apache.axis2.saaj.SOAPConnectionImpl.java in the 
Axis2 Source Repositoy, as the following code snippet shown, it 
never pass down MimeHeaders from SOAPMessage to the ServiceClient,
so all the SOAPMessage sent out with SOAPAction as "", Is this a bug?

==========================================
    public SOAPMessage call(SOAPMessage request, Object endpoint) throws
SOAPException {

        if (closed) {
            throw new SOAPException("SOAPConnection closed");
        }

        // initialize URL
        URL url;
        try {
            url = (endpoint instanceof URL) ? (URL) endpoint : new
URL(endpoint.toString());
        } catch (MalformedURLException e) {
            throw new SOAPException(e);
        }

        // initialize and set Options
        Options options = new Options();
        options.setTo(new EndpointReference(url.toString()));

        // initialize the Sender
        OperationClient opClient;
        try {
            serviceClient = new ServiceClient();
            opClient =
serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
        } catch (AxisFault e) {
            throw new SOAPException(e);
        }
        opClient.setOptions(options);

        if (request.countAttachments() != 0) { // SOAPMessage with
attachments
           
opClient.getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,
                                              Constants.VALUE_TRUE);
            return handleSOAPMessage(request, opClient);
        } else { // simple SOAPMessage
            return handleSOAPMessage(request, opClient);
        }
    }

private SOAPMessage handleSOAPMessage(SOAPMessage request,
                                          OperationClient opClient) throws
SOAPException {

        MessageContext requestMsgCtx = new MessageContext();
        try {
            requestMsgCtx.setEnvelope(toOMSOAPEnvelope(request));
            opClient.addMessageContext(requestMsgCtx);
            opClient.execute(true);

            MessageContext msgCtx =
opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            //TODO: get attachments

            return getSOAPMessage(msgCtx.getEnvelope());
        } catch (AxisFault e) {
            throw new SOAPException(e);
        }
    }

protected org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope(SOAPMessage
saajSOAPMsg)
            throws SOAPException {

        final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv =
               
SAAJUtil.toOMSOAPEnvelope(saajSOAPMsg.getSOAPPart().getDocumentElement());
        System.err.println("#### req OM Soap Env=" + omSOAPEnv);

        Map attachmentMap = new HashMap();
        final Iterator attachments = saajSOAPMsg.getAttachments();
        while (attachments.hasNext()) {
            final AttachmentPart attachment = (AttachmentPart)
attachments.next();
            if (attachment.getContentId() == null ||
                attachment.getContentId().trim().length() == 0) {
                attachment.setContentId(IDGenerator.generateID());
            }
            if (attachment.getDataHandler() == null) {
                throw new SOAPException("Attachment with NULL DataHandler");
            }
            attachmentMap.put(attachment.getContentId(), attachment);
        }

        insertAttachmentNodes(attachmentMap, omSOAPEnv);

//        printOMSOAPEnvelope(omSOAPEnv);

        return omSOAPEnv;
    }
====================================== 

Thanks,

Jian
-- 
View this message in context: http://www.nabble.com/-Axis2-saaj.SOAPConnectionImpl-does-not-handle-MimeHeaders-%28SOAPAction%29-tf2092238.html#a5767333
Sent from the Axis - Dev forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2]saaj.SOAPConnectionImpl does not handle MimeHeaders (SOAPActi

Posted by "Jian.Wu" <he...@gmail.com>.
Done. I filed Bug "AXIS2-1014" to track this issue.

Thanks a lot!

Jian
 

Davanum Srinivas wrote:
> 
> Jian,
> 
> Could you please open a bug/issue?
> 
> thanks,
> dims
> 
> On 8/11/06, Jian.Wu <he...@gmail.com> wrote:
>>
>> Hi,
>>
>> I looked into org.apache.axis2.saaj.SOAPConnectionImpl.java in the
>> Axis2 Source Repositoy, as the following code snippet shown, it
>> never pass down MimeHeaders from SOAPMessage to the ServiceClient,
>> so all the SOAPMessage sent out with SOAPAction as "", Is this a bug?
>>
>> ==========================================
>>     public SOAPMessage call(SOAPMessage request, Object endpoint) throws
>> SOAPException {
>>
>>         if (closed) {
>>             throw new SOAPException("SOAPConnection closed");
>>         }
>>
>>         // initialize URL
>>         URL url;
>>         try {
>>             url = (endpoint instanceof URL) ? (URL) endpoint : new
>> URL(endpoint.toString());
>>         } catch (MalformedURLException e) {
>>             throw new SOAPException(e);
>>         }
>>
>>         // initialize and set Options
>>         Options options = new Options();
>>         options.setTo(new EndpointReference(url.toString()));
>>
>>         // initialize the Sender
>>         OperationClient opClient;
>>         try {
>>             serviceClient = new ServiceClient();
>>             opClient =
>> serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
>>         } catch (AxisFault e) {
>>             throw new SOAPException(e);
>>         }
>>         opClient.setOptions(options);
>>
>>         if (request.countAttachments() != 0) { // SOAPMessage with
>> attachments
>>
>> opClient.getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,
>>                                               Constants.VALUE_TRUE);
>>             return handleSOAPMessage(request, opClient);
>>         } else { // simple SOAPMessage
>>             return handleSOAPMessage(request, opClient);
>>         }
>>     }
>>
>> private SOAPMessage handleSOAPMessage(SOAPMessage request,
>>                                           OperationClient opClient)
>> throws
>> SOAPException {
>>
>>         MessageContext requestMsgCtx = new MessageContext();
>>         try {
>>             requestMsgCtx.setEnvelope(toOMSOAPEnvelope(request));
>>             opClient.addMessageContext(requestMsgCtx);
>>             opClient.execute(true);
>>
>>             MessageContext msgCtx =
>> opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>>             //TODO: get attachments
>>
>>             return getSOAPMessage(msgCtx.getEnvelope());
>>         } catch (AxisFault e) {
>>             throw new SOAPException(e);
>>         }
>>     }
>>
>> protected org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope(SOAPMessage
>> saajSOAPMsg)
>>             throws SOAPException {
>>
>>         final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv =
>>
>> SAAJUtil.toOMSOAPEnvelope(saajSOAPMsg.getSOAPPart().getDocumentElement());
>>         System.err.println("#### req OM Soap Env=" + omSOAPEnv);
>>
>>         Map attachmentMap = new HashMap();
>>         final Iterator attachments = saajSOAPMsg.getAttachments();
>>         while (attachments.hasNext()) {
>>             final AttachmentPart attachment = (AttachmentPart)
>> attachments.next();
>>             if (attachment.getContentId() == null ||
>>                 attachment.getContentId().trim().length() == 0) {
>>                 attachment.setContentId(IDGenerator.generateID());
>>             }
>>             if (attachment.getDataHandler() == null) {
>>                 throw new SOAPException("Attachment with NULL
>> DataHandler");
>>             }
>>             attachmentMap.put(attachment.getContentId(), attachment);
>>         }
>>
>>         insertAttachmentNodes(attachmentMap, omSOAPEnv);
>>
>> //        printOMSOAPEnvelope(omSOAPEnv);
>>
>>         return omSOAPEnv;
>>     }
>> ======================================
>>
>> Thanks,
>>
>> Jian
>> --
>> View this message in context:
>> http://www.nabble.com/-Axis2-saaj.SOAPConnectionImpl-does-not-handle-MimeHeaders-%28SOAPAction%29-tf2092238.html#a5767333
>> Sent from the Axis - Dev forum at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>
>>
> 
> 
> -- 
> Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-Axis2-saaj.SOAPConnectionImpl-does-not-handle-MimeHeaders-%28SOAPAction%29-tf2092238.html#a5772572
Sent from the Axis - Dev forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2]saaj.SOAPConnectionImpl does not handle MimeHeaders (SOAPAction)

Posted by Davanum Srinivas <da...@gmail.com>.
Jian,

Could you please open a bug/issue?

thanks,
dims

On 8/11/06, Jian.Wu <he...@gmail.com> wrote:
>
> Hi,
>
> I looked into org.apache.axis2.saaj.SOAPConnectionImpl.java in the
> Axis2 Source Repositoy, as the following code snippet shown, it
> never pass down MimeHeaders from SOAPMessage to the ServiceClient,
> so all the SOAPMessage sent out with SOAPAction as "", Is this a bug?
>
> ==========================================
>     public SOAPMessage call(SOAPMessage request, Object endpoint) throws
> SOAPException {
>
>         if (closed) {
>             throw new SOAPException("SOAPConnection closed");
>         }
>
>         // initialize URL
>         URL url;
>         try {
>             url = (endpoint instanceof URL) ? (URL) endpoint : new
> URL(endpoint.toString());
>         } catch (MalformedURLException e) {
>             throw new SOAPException(e);
>         }
>
>         // initialize and set Options
>         Options options = new Options();
>         options.setTo(new EndpointReference(url.toString()));
>
>         // initialize the Sender
>         OperationClient opClient;
>         try {
>             serviceClient = new ServiceClient();
>             opClient =
> serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
>         } catch (AxisFault e) {
>             throw new SOAPException(e);
>         }
>         opClient.setOptions(options);
>
>         if (request.countAttachments() != 0) { // SOAPMessage with
> attachments
>
> opClient.getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,
>                                               Constants.VALUE_TRUE);
>             return handleSOAPMessage(request, opClient);
>         } else { // simple SOAPMessage
>             return handleSOAPMessage(request, opClient);
>         }
>     }
>
> private SOAPMessage handleSOAPMessage(SOAPMessage request,
>                                           OperationClient opClient) throws
> SOAPException {
>
>         MessageContext requestMsgCtx = new MessageContext();
>         try {
>             requestMsgCtx.setEnvelope(toOMSOAPEnvelope(request));
>             opClient.addMessageContext(requestMsgCtx);
>             opClient.execute(true);
>
>             MessageContext msgCtx =
> opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>             //TODO: get attachments
>
>             return getSOAPMessage(msgCtx.getEnvelope());
>         } catch (AxisFault e) {
>             throw new SOAPException(e);
>         }
>     }
>
> protected org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope(SOAPMessage
> saajSOAPMsg)
>             throws SOAPException {
>
>         final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv =
>
> SAAJUtil.toOMSOAPEnvelope(saajSOAPMsg.getSOAPPart().getDocumentElement());
>         System.err.println("#### req OM Soap Env=" + omSOAPEnv);
>
>         Map attachmentMap = new HashMap();
>         final Iterator attachments = saajSOAPMsg.getAttachments();
>         while (attachments.hasNext()) {
>             final AttachmentPart attachment = (AttachmentPart)
> attachments.next();
>             if (attachment.getContentId() == null ||
>                 attachment.getContentId().trim().length() == 0) {
>                 attachment.setContentId(IDGenerator.generateID());
>             }
>             if (attachment.getDataHandler() == null) {
>                 throw new SOAPException("Attachment with NULL DataHandler");
>             }
>             attachmentMap.put(attachment.getContentId(), attachment);
>         }
>
>         insertAttachmentNodes(attachmentMap, omSOAPEnv);
>
> //        printOMSOAPEnvelope(omSOAPEnv);
>
>         return omSOAPEnv;
>     }
> ======================================
>
> Thanks,
>
> Jian
> --
> View this message in context: http://www.nabble.com/-Axis2-saaj.SOAPConnectionImpl-does-not-handle-MimeHeaders-%28SOAPAction%29-tf2092238.html#a5767333
> Sent from the Axis - Dev forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers)

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org