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 Tom Jordahl <to...@macromedia.com> on 2004/03/09 15:46:23 UTC

RE: [PROPOSAL] Add invoke(Message) to Call and let SOAPConnection Impl to use it

+1

Looks like a reasonable enhancement.

--
Tom Jordahl
Macromedia Server Development

-----Original Message-----
From: Ias [mailto:iasandcb@tmax.co.kr] 
Sent: Tuesday, March 09, 2004 2:45 AM
To: axis-dev@ws.apache.org
Subject: [PROPOSAL] Add invoke(Message) to Call and let SOAPConnectionImpl
to use it

This proposal has three items:

#1. Adding invoke(Message) to Call

Here's the complete codes of the new method.

    public SOAPEnvelope invoke(Message msg) throws AxisFault {
        try {
            setRequestMessage( msg );
            invoke();
            msg = msgContext.getResponseMessage();
            if (msg == null) {
                if (msgContext.isPropertyTrue(FAULT_ON_NO_RESPONSE, false))
{
                    throw new
AxisFault(Messages.getMessage("nullResponse00"));
                } else {
                    return null;
                }
            }
            SOAPEnvelope res = null;
            res = msg.getSOAPEnvelope();
            return res;
        }
        catch (Exception exp) {
            if (exp instanceof AxisFault) {
                throw (AxisFault) exp ;
            }
            entLog.debug(Messages.getMessage("toAxisFault00"), exp);
            throw new AxisFault(
                    Messages.getMessage("errorInvoking00", "\n" + exp));
        }
    }

(Thanks to Dr. Ahn for his early idea and prototype on this.)

#2. Changing SOAPConnectionImpl to use invoke(Message)

Here's the modified call method.

    public SOAPMessage call(SOAPMessage request, Object endpoint)
        throws SOAPException {
        if(closed){
            throw new
SOAPException(Messages.getMessage("connectionClosed00"));
        }
        try {
            Call call = new Call(endpoint.toString());
 
((org.apache.axis.Message)request).setMessageContext(call.getMessageContext(
));
            Attachments attachments = ((org.apache.axis.Message)
                    request).getAttachmentsImpl();
            if (attachments != null) {
                Iterator iterator = attachments.getAttachments().iterator();
                while (iterator.hasNext()) {
                    Object attachment = iterator.next();
                    call.addAttachmentPart(attachment);
                }
            }
            
            String soapActionURI = checkForSOAPActionHeader(request);
            if (soapActionURI != null)
                call.setSOAPActionURI(soapActionURI);
            
            call.setTimeout(timeout);
            call.setReturnClass(SOAPMessage.class);
          call.invoke((Message) request);
            return call.getResponseMessage();
        } catch (java.net.MalformedURLException mue){
            throw new SOAPException(mue);
        } catch (org.apache.axis.AxisFault af){
            throw new SOAPException(af);
        } catch (java.rmi.RemoteException re){
            throw new SOAPException(re);
        }
    }

As you might recognize, there' no SOAPEnvelope's involvement in this job.
In addition, we don't need MessageContext to relay character encoding
stuffs and Call to make a Message from an Envelope like
invoke(SOAPEnvelope). In other words, it's simplification.

#3. Supporting passing MimeHeaders to HTTP headers

Adding the following codes to writeToSocket method of HTTPSender. (Perhaps
between if (posting) { } and if (null != httpConnection) { )

        MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
        if (mimeHeaders != null) {
            for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext(); ) {
                MimeHeader mimeHeader = (MimeHeader) i.next();
                header.append(mimeHeader.getName())
                .append(": ")
                .append(mimeHeader.getValue())
                .append("\r\n");
            }
        }

This implementation is inspired by http://marc.theaimsgroup.com/?l=axis-
user&m=107859760408710&w=2 . (And Sun's SAAJ 1.2 in JWSDP 1.3 supports
that.)

Looking forward to your response,

Ias

=========================================================
Lee, Changshin (Korean name)
Ias (International name)
               Company Web Site: http://www.tmax.co.kr
               Personal Web Site: http://www.iasandcb.pe.kr
---------------------------------------------------------
JSR 201, 204, 222 and 224 Expert Group Member
Apache Web Services Project Member
R&D Center
Tmax Soft, Inc.
=========================================================