DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14065>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14065 Message.addAttachmentPart() != Call.addAttachmentPart() ------- Additional Comments From [EMAIL PROTECTED] 2002-10-30 14:55 ------- You can use this client class with any service that has a valid messaging method signature to reproduce the problem. You obviously may have to touch up the endpoint url and the location of a file to send as the attachment. If you use tcpmon and change the method invocation in main () from works() to does_not_work() you'll see the behavior I mentioned. Hope this is useful. package soaptest.client; import java.io.ByteArrayInputStream; import java.io.File; import java.net.URL; import java.util.*; import javax.activation.DataHandler; import javax.activation.FileDataSource; import org.apache.axis.*; import org.apache.axis.attachments.AttachmentPart; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.message.*; import org.apache.axis.attachments.* ; import org.apache.axis.transport.http.HTTPConstants; import org.w3c.dom.*; public class SOAPTestClient { public SOAPTestClient() { } public boolean works () throws Exception { boolean rc = true; String endPointURLString = "http://localhost:8080/axis/services/SOAPTestServer" ; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new URL(endPointURLString)); javax.xml.soap.MessageFactory messageFactory = javax.xml.soap.MessageFactory.newInstance(); javax.xml.soap.SOAPMessage soapMessage = messageFactory.createMessage(); javax.xml.soap.SOAPPart soapPart = soapMessage.getSOAPPart() ; javax.xml.soap.SOAPEnvelope requestEnvelope = soapPart.getEnvelope(); javax.xml.soap.SOAPBody body = requestEnvelope.getBody(); javax.xml.soap.SOAPBodyElement operation = body.addBodyElement (requestEnvelope.createName("EchoTest")) ; Vector dataHandlersToAdd = new Vector () ; dataHandlersToAdd.add (new DataHandler (new FileDataSource(new File ("D:\\documents\\celparser1.cpp")))) ; if (dataHandlersToAdd != null) { ListIterator dataHandlerIterator = dataHandlersToAdd.listIterator () ; while (dataHandlerIterator.hasNext()) { DataHandler dataHandler = (DataHandler) dataHandlerIterator.next() ; javax.xml.soap.SOAPElement element = operation.addChildElement(requestEnvelope.createName("source")); javax.xml.soap.AttachmentPart attachment = soapMessage.createAttachmentPart(dataHandler); call.addAttachmentPart(attachment); element.addAttribute(requestEnvelope.createName ("href"), "cid:" + attachment.getContentId()); } } Attachments attachments = ((org.apache.axis.Message ) soapMessage).getAttachmentsImpl() ; SOAPEnvelope retSOAPEnvelope = call.invoke ((org.apache.axis.message.SOAPEnvelope )requestEnvelope); return rc; } public boolean does_not_work() throws Exception { boolean rc = true; String endPointURLString = "http://localhost:8080/axis/services/SOAPTestServer" ; javax.xml.soap.SOAPConnectionFactory soapConnectionFactory = javax.xml.soap.SOAPConnectionFactory.newInstance(); javax.xml.soap.SOAPConnection soapConnection = soapConnectionFactory.createConnection(); javax.xml.soap.MessageFactory messageFactory = javax.xml.soap.MessageFactory.newInstance(); javax.xml.soap.SOAPMessage soapMessage = messageFactory.createMessage(); javax.xml.soap.SOAPPart soapPart = soapMessage.getSOAPPart() ; javax.xml.soap.SOAPEnvelope requestEnvelope = soapPart.getEnvelope(); javax.xml.soap.SOAPBody body = requestEnvelope.getBody(); javax.xml.soap.SOAPBodyElement operation = body.addBodyElement (requestEnvelope.createName("EchoTest")) ; Vector dataHandlersToAdd = new Vector () ; dataHandlersToAdd.add (new DataHandler (new FileDataSource(new File ("D:\\documents\\celparser1.cpp")))) ; if (dataHandlersToAdd != null) { ListIterator dataHandlerIterator = dataHandlersToAdd.listIterator () ; while (dataHandlerIterator.hasNext()) { DataHandler dataHandler = (DataHandler) dataHandlerIterator.next() ; javax.xml.soap.SOAPElement element = operation.addChildElement(requestEnvelope.createName("source")); javax.xml.soap.AttachmentPart attachment = soapMessage.createAttachmentPart(dataHandler); soapMessage.addAttachmentPart(attachment); element.addAttribute(requestEnvelope.createName ("href"), "cid:" + attachment.getContentId()); } } Attachments attachments = ((org.apache.axis.Message ) soapMessage).getAttachmentsImpl() ; javax.xml.soap.SOAPMessage returnedSOAPMessage = soapConnection.call(soapMessage, endPointURLString); return rc; } public static void main(String[] args) { try { SOAPTestClient soapTestClient = new SOAPTestClient(); if (soapTestClient.works()) { System.out.println("Attachments sent and received ok!"); System.exit(0); } } catch ( Exception e ) { System.err.println(e); e.printStackTrace(); } System.exit(18); } }