SOAP Attachment

Hi,
I have a lot of difficulties to understand the use of WS and Attachments.
I have a form that use an XML Schema.
Each field is binded to its corresponding node.
Do i have to create a specifically node that will get the "SOAP.streamFromString" string of the attachment?
Is it the good way or is there another one?
Thanks by advance for any help
Samuel

This note answers your question:
Sending and receiving large files using web services
Also answered your on the J2EE forum.
Mike

Similar Messages

  • "Content is not allowed in prolog" with SOAP Attachment

    I'm writing an application using SAAJ that sends a soap message to a servlet which responds with some information, including HTML which the client application will display. The HTML has to go into a SOAP attachment so the tags won't get confused with XML.
    I had the whole thing working with plain text sending within a normal node, and I only switched a few lines to make that text an attachment with HTML instead, but now I'm getting the exception "Content is not allowed in prolog" on the Client side when it tries to create the envelope from the SOAPMessage.
    Code for building answering SOAPMessage with attachment (Servlet to Client)
         public static SOAPMessage buildXML(Message newMessage){
              SOAPMessage msg = null;
              try {
                   MessageFactory msgFactory = MessageFactory.newInstance();
                   msg = msgFactory.createMessage();
                   // Create an envelope in the message
                   SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
                   msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
                   msg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
                   //Get hold of the the body
                   SOAPBody body = envelope.getBody();
                   SOAPElement soap_message = body.addChildElement("MESSAGE");
                   if (newMessage.message_type != null){
                        SOAPElement soap_message_type = soap_message.addChildElement("MESSAGETYPE");
                        soap_message_type.addTextNode(newMessage.message_type);
                   if (newMessage.questionID != 0){
                        SOAPElement soap_questionID = soap_message.addChildElement("QUESTIONID");
                        soap_questionID.addTextNode("" + newMessage.questionID);
                   if (newMessage.username != null){
                        SOAPElement soap_username = soap_message.addChildElement("USERNAME");
                        soap_username.addTextNode(newMessage.username);
                   if (newMessage.password != null){
                        SOAPElement soap_password = soap_message.addChildElement("PASSWORD");
                        soap_password.addTextNode(newMessage.password);
                   if (newMessage.message_text != null){
                        AttachmentPart soap_message_text = msg.createAttachmentPart("<html><body>" + newMessage.message_text + "</body></html>", "text/html");
                        soap_message_text.setContentId("MESSAGETEXT");
                        msg.addAttachmentPart(soap_message_text);
                        //SOAPElement soap_message_text = soap_message.addChildElement("MESSAGETEXT");
                        //soap_message_text.addTextNode(newMessage.message_text);
                   if (newMessage.sampleString != null){
                        SOAPElement soap_password = soap_message.addChildElement("SAMPLESTRING");
                        soap_password.addTextNode(newMessage.sampleString);
                   SOAPElement tmpEl;
                   for (int i=0; i<newMessage.numArrayUsed; i++){
                        tmpEl = soap_message.addChildElement("SAMPLEINT");
                        tmpEl.addTextNode("" + newMessage.sampleInt);
                   msg.saveChanges();
              } catch (Exception e) {
                   e.printStackTrace();
              return msg;
    You can see in the area where it adds MESSAGETEXT there are two clients commented out which work. The three lines above it are what changed to make it an attachment instead.
    Code in Client for recieving reply from Servlet
    SOAPMessage reply = connection.call(soap_msg, endpoint);
    System.out.println("\nReceived reply from: " + endpoint);
    reply.writeTo(System.out);
    System.out.println("");
    reply_msg = ProcessXML.parse(reply);This is the console output:
    Edit: These forums seem to be inserting an extra > before the <?xml version="1.0" encoding="UTF-8"?> line, but it doesn't exist in the code I'm pasting
    Received reply from: http://localhost:8080/kuj/CaseStudyServlet
    ------=_Part_2_371807.1137465625031
    Content-Type: text/xml; charset=UTF-8
    <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><MESSAGE><MESSAGETYPE>deliverquestion</MESSAGETYPE><QUESTIONID>1</QUESTIONID><USERNAME>zac</USERNAME></MESSAGE></SOAP-ENV:Body></SOAP-ENV:Envelope>
    ------=_Part_2_371807.1137465625031
    Content-Type: text/html
    Content-Id: MESSAGETEXT
    <html><body>This is an Array sort Question. You will be given 10 random integers and you must sort and return them in the order of greatest to least.</body></html>
    ------=_Part_2_371807.1137465625031--
    ERROR:  'Content is not allowed in prolog.'
    17-Jan-2006 02:40:25 com.sun.xml.messaging.saaj.soap.EnvelopeFactory createEnvelope
    SEVERE: SAAJ0511: Unable to create envelope from given source
    com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
         at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:111)
         at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:39)
         at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:98)
         at com.zacwittedesign.xml.ProcessXML.realParse(ProcessXML.java:32)
         at com.zacwittedesign.xml.ProcessXML.parse(ProcessXML.java:26)
    (snip)And this is the beginning of the code for extracting the info from the SOAPMessage on the Client side:
    private static Message realParse(SOAPMessage msg){
              Message newMessage = new Message();
              try {
                   SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
                   SOAPBody body = envelope.getBody();
    (snip)It dies on SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
    Does anyone know what I'm doing wrong?

    I suppose I should also include the bit where the Servlet actually SENDs the resulting SOAPMessage
    SOAPMessage msg = ProcessXML.buildXML(outMessage);
    // try to send it
    try {
         response.setContentType("text/xml");
         msg.writeTo(response.getOutputStream());

  • Unique Problem: Returning SOAP+ Attachment using a class based webservice

    Hi everyone,
    Im trying to return a Soap+ attachment response back using the following:
    attachDoc(byte[] bdoc, String sTransactionNumber,
                   String sRequestedType)
    Where byte[] is the attachment and the 2 string parameters are soap message contents.
    The attachment is attached successfully to the message and i can send a response back to the clients console using :
    message.writeTo(System.out);
    My problem is that i dont know how to return this soapmessage+attachment back to the client.
    Ive tried using the return type of the method as :
    public SOAPMessage attachDoc(byte[] bdoc, String sTransactionNumber,
                   String sRequestedType)
    but i cant return a SOAPMessage return type in axis.
    Does anyone have any clues how i should sort this out so that the client gets the SOAPMessage and attachment when the method is called ?
    Please help :S
    Thanks,

    I dunno if this is what you asked for....
    Hope this helps a bit
    You may want to check this link out
    http://www-unix.globus.org/mail_archive/discuss/2007/02/msg00037.html
    MessageContext msgContext = MessageContext.getCurrentContext();
    File file = new File("filename.txt");
    org.apache.axis.attachments.AttachmentPart replyPart=
    new org.apache.axis.attachments.AttachmentPart(new DataHandler(new
    FileDataSource(file)));
    Message rspMsg= msgContext.getResponseMessage();
    rspMsg.addAttachmentPart(replyPart);
    so ur basically adding the file to the reply message.
    The link i gave has a better description, it has the entire process of sending file to server and downloading file from server codes.

  • How to process a SOAP Attachment in XI

    Hi,
    I have a SOAP-RFC-SOAP Synchronous scenario. Here the SOAP Message comes with an attachment. I need to process the SOAP Attachment through XI and need to map the content to the RFC and send the response back to the webservice. Here PayloadSwapBean does not work in Sender soap Adapter. Is there any other option of achieving this.
    Thanks,
    Bhargav

    Ask Michal
    The specified item was not found.
    Need need to implement the other direction.
    Regards
    Stefan

  • Exception when trying to create a soap attachment javax.activation. Unsuppo

    I am trying to pass an object String [] as a soap attachment.
    Reading the docs, if I pass a parameter as type datahandler, it is automatically treated as an Attachment.
    I used the constructor DataHandler (Object obj, String mimeType)
    where the object was my StringArray, and MIME is the XML representation of
    a java type, which according to weblogic docs is NMTOKENS,IDREF or ENTITIES.
    It threw the same error for the other two.
    Am I using DataHandler correctly, is MIME the SOAP representation of the Java Object in memory.
    Thanks for any help
    Tony

    I am trying to pass an object String [] as a soap attachment.
    Reading the docs, if I pass a parameter as type datahandler, it is automatically treated as an Attachment.
    I used the constructor DataHandler (Object obj, String mimeType)
    where the object was my StringArray, and MIME is the XML representation of
    a java type, which according to weblogic docs is NMTOKENS,IDREF or ENTITIES.
    It threw the same error for the other two.
    Am I using DataHandler correctly, is MIME the SOAP representation of the Java Object in memory.
    Thanks for any help
    Tony

  • How to download a SOAP attachment using pl/sql

    Gurus,
    I have a custom pl sql application that is web services based. The custom pl sql application invokes the external web services and updates Oracle Field Service application.
    One of the new requirements is to get the signatures from SOAP Attachments (a binary file) and attach it to Field Services transactions in Oracle.
    Does anyone has an example of how to download the SOAP attachment file from web service using pl/sql.
    The pl sql program uses UTL_HTTP to access web services.
    Much Thanx.

    I think you may be in the wrong forum, but anyways...
    What I think your looking for is the htp.print('insert html here'); function. It's plsql, and writes out html to the web server that calls it.
    if you search for htp.print you should find loads of examples.
    hope this helps.
    Merv.

  • SOAP Attachment & performances for WLI

    Dear all,
    I am implementing webservices, accepting a SOAP attachment as parameter. The implementation is based on Workshop / WLI jws file. The web service is RPC style since WorkShop is unable to generate a correct WSDL file with SOAP atttachment & document style (known limitation from BEA).
    My problem is concerning attachments. Indeed, in my mind, attaachement are there in order to prevent extra load into the XML parser and to speedup processing and avoid heavy use of memory.
    So I made some tests with a simple soap request and attachments. Here are the results (I calculate the time to send and receive response from web service), the web service itself just prints the content type, anything else.
    Attachement size | Time
    39 kb 344ms
    78 kb 406ms
    155 kb 484ms
    300 kb 750ms
    463 kb 1000ms
    1389 kb 4600ms
    2700 kb 23609ms
    5500 kb 140000ms
    Of course, the client and server are running on the same machine and are using the loopback interface. So there is no network bootleneck to take into account.
    As conclusion, we can see that for small messages, (<300kb) the curve is good... But performances start to fall drastically with messages larger than 300kb. This is not a problem of memory but CPU usage (fully used diring the 1400 seconds).
    Any idea, any opened cases ?
    Thansk for all,
    Pascal Bourgeois

    This post :
    http://soastuff.wordpress.com/2007/06/06/handling-opaque-datatypes-in-bpelesb/
    Describes how to use the opaque-schema for sending files over the ESB.
    Hope you can use this.
    or do you want to use the soap-headers for this?

  • Soap Attachment Stream Error

    11:56:37 F01F Soap Attachment Stream Error: [8911], File Size = 1120068 Written Size=131072
    11:56:37 F01F Soap Attachment Stream Error: [8911], File Size = 1120068 Written Size=131072
    11:56:37 F01F Error streaming an attachment [8911]
    11:56:37 F277 Soap Attachment Stream Error: [8911], File Size = 673015 Written Size=131072
    11:56:37 F277 Soap Attachment Stream Error: [8911], File Size = 673015 Written Size=131072
    11:56:37 F277 Error streaming an attachment [8911]
    What are these?

    Originally Posted by swishewk
    11:56:37 F01F Soap Attachment Stream Error: [8911], File Size = 1120068 Written Size=131072
    11:56:37 F01F Soap Attachment Stream Error: [8911], File Size = 1120068 Written Size=131072
    11:56:37 F01F Error streaming an attachment [8911]
    11:56:37 F277 Soap Attachment Stream Error: [8911], File Size = 673015 Written Size=131072
    11:56:37 F277 Soap Attachment Stream Error: [8911], File Size = 673015 Written Size=131072
    11:56:37 F277 Error streaming an attachment [8911]
    What are these?
    I believe the lines with the file size/written size are files in excess of the limit set in Data Synchronizer.

  • SOAP Attachment question

    Hi!
    I've got a question about SOAP Attachment. It is possible to use "Datahandler" class to attach a file. But is it possible to put the datahandler in a business class ( as an attribute of the class), and the business class is a parameter of the service?
    Thank you for your help!
    Best Regards,
    Nguyen Gilbert

    I tried making the DataHandler object as a attribute of the parameter object and there were some exceptions. I think weblogic does not allow that.

  • SOAP attachment - module development?

    Hi,
    I have an IDOC -> SOAP scenario where I have to call a webservice that uses SOAP attachment.
    Example:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ueb="IBrokerInterface">
       <soapenv:Header/>
       <soapenv:Body>
          <ueb:TEBIBrokerInterface_PublishWS>
             <aClientId>TEST</aClientId>
             <aMessage>cid:file.xml</aMessage>
             <aDuplicates>0</aDuplicates>
          </ueb:TEBIBrokerInterface_PublishWS>
       </soapenv:Body>
    </soapenv:Envelope>
    The "file.xml" has to be a SOAP attachment.
    If I use a SOAP receiver channel how do I get the IDOC payload moved into a SOAP attachment and still keep the SOAP envelope?
    Can this only be done with module development?
    Thanks Rasmus

    Hi Rasmus,
    You cannot create an attachment in mapping.
    In PI 7.1 there will be a Java Mapping API for working with attachments, but the code will be similar to an adapter module. It will not be possible with XSLT.
    Regards
    Stefan

  • Soap Attachment write problem

    Hello All,
    I'm seeing the error message given below. I'd been trying to write a soap attachment to a file output stream. I did the same thing in WSAD and it worked. But when I tried to work on unix box.. it wasnt supporting activation.jar and mail.jar resulting the error below. I'm urgently in need of help. Please help me. [java] at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source)
    [java] at javax.activation.DataHandler.writeTo(Unknown Source)
    [java] at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1147) [java] at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:668)
    [java] at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233) [java] at weblogic.webservice.core.soap.SOAPMessageImpl.writeMimeMessage(SOAPMessageImpl.java:589) [java] at weblogic.webservice.core.soap.SOAPMessageImpl.writeTo(SOAPMessageImpl.java:513) [java] at
    I think there is a problem with the activation.jar and mail.jar.
    Please let me know about this problem if you have any idea since it is very urgent.
    I'm using Weblogic server which is on the solaris box and it is not supporting the activation.jar and mail.jar. The same worked on WSAD.
    Please advise.
    Thanks in advance,
    Vamshi

    Hi Hasan,
      Please, try to implement next xslt mapping before message mapping.
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:stylesheet version="1.0" xmlns:ns0="http://www.w3.org/1999/XSL/Transform" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:ns2="https://onlineservice.creditreform.de/webservice/0400-0005">
       <ns0:template match="node() | @*">
          <ns0:copy>
             <ns0:apply-templates select="node() | @*"/>
          </ns0:copy>
       </ns0:template>
       <ns0:template match="xop:Include"/>
    </ns0:stylesheet>
    Regards, Dzmitry

  • Modify the SOAP attachment name

    hi,
    I have a Service with Party, which sends messages in SOAP format to XI.
    When the SOAP message sent to XI contains a '&' character in its attachment name, the message gets failed to processed through XI.
    I believe this happens since '&' character is a wildcard character in XML hence XI expects a escape character sequence following it and cannot parse through the '&' character. Also as per the IR tests executed for the SOAP message, when the '&' is replaced with its escape sequence the message is processed through successfully.
    Is it possible to replace the '&' character with its escape sequence in the SOAP attachment name before it is processed by the XI Integration Engine. That is at the adapter level?
    regards,
    Diptee
    Edited by: diptee s on Oct 26, 2010 4:47 PM

    hi,
    i have created the Java Mapping .
    in the pdf document How Tou2026Work with Character Encodings in Process Integration from SAP, for the Escape sequences it is said that for adding Escape sequences to the unescaped characters, add the Java mapping before the required mapping.
    however, i am not able to test the interface in the IR even after adding the new Java mapping.
    please suggest.
    regards,
    Diptee

  • Return zip file as soap attachment  from server..

    Dear Friends,
    Requirement:
    I would like to download a zip file from server(tomcat) with soap attachment using wsdl.
    I have tried googling but didn't get exact information and samples on this.
    Please help me on this and it would be helpful if u can provide me one sample on this.
    Thanks in advance.
    Cheers
    Cap

    pls http://www.catb.org/~esr/faqs/smart-questions.html#writewell
    How To Ask Questions The Smart Way
    Eric Steven Raymond
    Rick Moen
    Write in clear, grammatical, correctly-spelled language
    We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding (often enough to bet on, anyway). Answering questions for careless and sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.
    So expressing your question clearly and well is important. If you can't be bothered to do that, we can't be bothered to pay attention. Spend the extra effort to polish your language. It doesn't have to be stiff or formal - in fact, hacker culture values informal, slangy and humorous language used with precision. But it has to be precise; there has to be some indication that you're thinking and paying attention.
    Spell, punctuate, and capitalize correctly. Don't confuse "its" with "it's", "loose" with "lose", or "discrete" with "discreet". Don't TYPE IN ALL CAPS; this is read as shouting and considered rude. (All-smalls is only slightly less annoying, as it's difficult to read. Alan Cox can get away with it, but you can't.)
    More generally, if you write like a semi-literate b o o b you will very likely be ignored. So don't use instant-messaging shortcuts. Spelling "you" as "u" makes you look like a semi-literate b o o b to save two entire keystrokes.

  • Convert SOAP Attachment into SOAP Body

    Hi,
    I am getting the response from external system through SOAP attachment, how to convert it into soap body.
    Is there any other alternative apart from PayloadSwapBean, if not, let me know the steps of the same.
    Regards,
    B.Anandh

    Hi Krish,
    It is not possible to use adapter module (Custom or standard) in SOAP sender adapter and this thing is clearly mentioned in Help.sap.
    But you can use axis adapter to use module (Axis adapter is extention to soap adapter). It provides modules which are flexible enough to fulfil your requirment.
    If you are using Receiver SOAP adapter then youn can either have PayloadSwipeBean or your own adapter module. And it is possible to convert the attachment to the payload using custom module.(I have Done this)
    There is method available getAttachment() of type. Just Check API.
    Thanks
    Sunil Singh

  • SOAP Attachements in Webservices

    Hi,
    Is there any way to send SOAP attachements while accessing the weblogic Webservices,
    i.e As a part of my client program, I want to attach a document/image to a SOAP
    message.
    Thanks in advance
    pidix

    user10455639 wrote:
    Yes I can..what I still dont understand from yourr email is why are you askign this..
    "if you can get the soap header"
    Because any header we should be able to retrieve from this context...Because I saw the following statement from [JavaDoc | http://e-docs.bea.com/wls/docs103/javadocs/weblogic/wsee/jws/JwsContext.html#getInputHeaders()].
    <<<<<<<<<<
    ....The SOAP headers used by WebLogic Workshop to manage conversations are included in the list of headers returned.
    <<<<<<<<<<
    If it works, then just use it :) because it is public supported
    Edited by: LJ on Apr 23, 2009 10:04 PM
    Edited by: LJ on Apr 23, 2009 10:21 PM

  • Unable to send a SOAP attachment(pdf) in a BPEL process

    Dear Forum,
    I have a requirement to attach a pdf and send it as part of a BPEL process response. Following are the details,
    1) I have a webservice which does the logic of building the pdf and returns it as a SOAP attachment. I have tested this service through SOAP UI and it works fine.
    2) I have a BPEL process which invokes the above webservice and returns the received pdf as a SOAP attachment.
    3) Since BPEL designer doesn't directly support the MIME attachments, I have modified the WSDL related to BPEL process to include MIME parts. Followed the steps as mentioned in the SOA suite documentation - http://docs.oracle.com/cd/B14099_19/integrate.1012/b14448/manipdoc.htm#BABDEEEB
    4) I have tested my bpel service through SOAP UI tool (cannot test it in 'em' console since my service has mime parts) but unable to receive the pdf attachment. BPEL process is throwing the following exception,
    <Mar 26, 2012 5:21:07 PM EDT> <Warning> <oracle.adfinternal.view.faces.renderkit
    .rich.TreeRendererUtils> <BEA-000000> <Context menu child is not a RichMenu>
    <Mar 26, 2012 5:22:19 PM EDT> <Error> <oracle.soa.bpel.engine.ws> <BEA-000000> <
    got RuntimeException
    java.lang.NullPointerException
    at oracle.integration.platform.attchmnt.AttachmentManagerImpl.encodeProp
    erties(AttachmentManagerImpl.java:569)
    at oracle.integration.platform.attchmnt.AttachmentManagerImpl.insertAtta
    chment(AttachmentManagerImpl.java:483)
    at oracle.integration.platform.attchmnt.AttachmentManagerImpl.storeAttac
    hment(AttachmentManagerImpl.java:189)
    at oracle.integration.platform.attchmnt.AttachmentManagerImpl.storeAttac
    hment(AttachmentManagerImpl.java:144)
    From the SOAP UI response(error message), I found that 'Content-Type' for this request is coming as 'text/xml' rather than 'mimemultipartrelated'. Is it not possible to send pdf attachments through BPEL? Please provide your inputs to resolve this issue. I am stuck up with this issue for a while now.

    Hi Vamsee,
    In my case pdf is returned by a webservice, not from any physical location. The example given there shows attaching a pdf file from physical location. But I will get the pdf as part of another webservice response. So I am assigning the attachment to a bpel variable after getting the webservice response. This is where my bpel process is throwing an exception mentioned above.
    Regards,
    Satya.

Maybe you are looking for

  • Iphone 6 won't backup to icloud

    My husband and I upgraded from iphone 4s to iphone 6. We used to share the same apple id, but ran into an issue where a contact would call him but it would appear on my phone was well. It was suggested to alleviate that issue that we should create a

  • Runtime is not working

    Hi all, I am trying to run SQLLDR command using java. i am using Runtime class to run the command. but the command is not executing. After executing the system get hanged. please suggest me to solve this. My code is, Runtime rt = Runtime.getRuntime()

  • A problem with treemap

    In a file, I have 400, 000 lines of data. There are around 16000 keys. Each key can have multiple values. eg: Key - Var1 - Var2 5 - 132.1 - 0.678 5 - 128.5 - 0.523 2 - 110.0 - 0.253 6 - 20.0 - 0.245 I sorted using TreeMap. However, only 12463 keys ge

  • Crazy Keyboard Shortcut

    I was typing away in Illustrator the other day and I accidently hit some keys on the lower left of the keyboard....not sure if it was Shift or Ctrl or something..... Anyway, now when I try to type a question mark, I am getting a É instead. I have not

  • Urgent WLC 5508

    Hi Guys, I urgently need help in getting a Cisco 5508 WLC image transferred to the device via the boot menu. I went through the process and it says do not transfer an aes file I need a RTOS image. But can someone please help me find the RTOS image? A