Creating EbXML from a stream

I want to be able to create an EbXMLMessageImpl object from a stream, and I am running into errors.
The following code makes teh EbXMLMessageImpl into a stream, and then I want to put the stream back into an EbXMLMessageImpl. (I am testing what I will have to do if I receive a stream and needed to convert it to a EbXMLMessageImpl object.)
Am I setting the MIME headers correctly? Can the stream represent a multipart/related message?
Here is a small sample of the code:
public static void main(String [] args)
try
EbXMLMessageFactoryImpl factory = new EbXMLMessageFactoryImpl();
// ProviderConnectionFactory factory = ProviderConnectionFactory.newInstance();
// ProviderConnection connection = factory.createConnection();
// MessageFactory fact = connection.createMessageFactory("ebxml");
EbXMLMessageImpl message = (EbXMLMessageImpl)factory.createMessage();
EbXMLMessageImpl ebxmlMsg = message;
ByteArrayInputStream stream = new ByteArrayInputStream("<? xml version='1.0' ?><BEGIN></BEGIN>".getBytes());
message.setAction("dasdf");     ebxmlMsg.setSender(new Party("[email protected]"));
     ebxmlMsg.setReceiver(new Party("edwardbying@[email protected]"));
     Service service = new Service("SupplierOrderProcessing");
     ebxmlMsg.setRefToMessageId("[email protected]");
     ebxmlMsg.setCPAId("http://example.com/cpas/ourcpawithyou.xml");
     ebxmlMsg.setConversationId("20001209-133003-28572");
     ebxmlMsg.setService(service);
     ebxmlMsg.setAction("NewOrder");
     Manifest manifest = new Manifest("manifest", "1.0");
     Reference ref = new Reference("pay01", "cid:pay01",
                    "http://regrep.org/gci/purchaseorder");
     Schema schema = new Schema(
                    "http://regrep.org/gci/purchaseorder.xsd",
                    "1.0");
     ref.setSchema(schema);
     Description desc = new Description("en-us");
     desc.setText("PurchaseOrder for widgets");
     ref.setDescription(desc);
     manifest.addReference(ref);
     ebxmlMsg.setManifest(manifest);
SOAPPart part = message.getSOAPPart();
SOAPEnvelope envelope = part.getEnvelope();
envelope.getHeader().detachNode();
SOAPHeader header = envelope.addHeader();
Name eb_messageHeader = envelope.createName("MessageHeader","eb","http://www.ebxml.org/namespaces/messageHeader");
header.addHeaderElement(eb_messageHeader);
// message.saveChanges();
AttachmentPart attachment = message.createAttachmentPart("<? xml version='1.0' ?><BEGIN></BEGIN>", "text/plain");
attachment.setContentType("text/xml");
message.addAttachmentPart(attachment);
ByteArrayOutputStream out = new ByteArrayOutputStream();
message.writeTo(out);
message.writeTo(System.out);
System.out.println(System.getProperty("user.dir"));
FileOutputStream fileout= new FileOutputStream("file.dat");
message.writeTo(fileout);
fileout.flush();
fileout.close();
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
MimeHeaders mimeheader = new MimeHeaders();
LineNumberReader reader = new LineNumberReader(new InputStreamReader( new ByteArrayInputStream(out.toByteArray())));
String line = reader.readLine();
System.out.println(line);
String bondary = line.substring(2, line.length());
System.out.println(bondary);
mimeheader.addHeader("Content-type","multipart/related; boundary=\""+bondary + "\"");
EbXMLMessageImpl impl = new EbXMLMessageImpl(mimeheader,in);
}catch(Exception e)
e.printStackTrace();
System.exit(0);

Hi,
I am also facing a problem creating an ebXMLMessageImpl object from a stream.
The thing I am doing differently to read the headers : I create a MimeMessage from the stream and get the headers from there and then populate MimeHeaders object with it.
I then use the MimeHeaders and the input stream to create
a ebXMLMessageImpl object.
Among other exceptions I get during my trial and error, I am getting an exception
Warning: Error occurred using JAXP to load a SAXParser. Will use Aelfred instead
Exception in thread "main" java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.dom4j.TextImpl at com.sun.xml.messaging.jaxm.ebxml.EbXMLMessageImpl.fillInHeaders(EbXML
MessageImpl.java:137)
at com.sun.xml.messaging.jaxm.ebxml.EbXMLMessageImpl.<init>(EbXMLMessage
Impl.java:117)
If anybody knows a solution to create a ebXML message from an input stream - or know how I can solve this exception - please reply
Thanks,
Anant.

Similar Messages

  • Each time I create a new album in IPhoto, photos from another album or from photo stream are automatically dumped into the new album..  how do I create a blank album and then import photos from a flash drive into the new album?

    each time I create a new album in IPhoto, photos from another album or from photo stream are automatically dumped into the new album..  how do I create a blank album and then import photos from a flash drive into the new album?

    just import the iPhoto
    Surely you meant "just import the photo"?  The Spell checker is dangerously creative !

  • If I delete photos from photo stream to create space will it also delete my back-ups in 'Photos' automatically stored under 'photo stream'?

    I need to create space on my iphone4. I have moved all my photo stream pics to 'Photos' Library on my mac which were automatically labelled 'photo stream' there. Now I want to delete all my photo stream, however I am afraid it will delete the newly transfered pics labelled 'photo stream' in the library. Is it safe to delete?

    If you enabled Automatic Import in iPhone>Preferences>Photo Stream, you photo stream photos should be safely imported to your iPhoto library.  You can check by control-clicking on any photo stream photos; if it says "Show in Library" on the pop-up that opens, it has been imported to your library.  Once the photos are in your iPhoto library, you can safely delete them from photo stream on your phone.
    (You can test this by taking a test photo on your phone, waiting for it to upload to photo stream and import to your iPhoto library, then deleting it from photo stream on your phone and confirming that it is still in your iPhoto library on your Mac.)

  • How do I create events from my photo stream?

    My pics are importing into an event called "October 2011 Photo Stream" but I want to break those down into smaller events. How do I do that?

    Like any Event.
    Flag the photo(s) and go Events -> Create Event from Flagged Photos or Move Flagged Photos to selected Event.
    Regards
    TD

  • Error creating document from using list using Document Template

    Hi All,
    I am trying to create a document from sharepoint list and upload it to a document library using item added and item updated event receiver methods. I can create metadata from list update in document library but unable to open the document. The error message
    I get is "we're sorry. we can't open "Filename" because we found a problem with its contents. no error detail available". Please see the below code.
    SPSecurity.RunWithElevatedPrivileges(delegate()
                       try
                           string TemplateUrl = string.Empty;
                           SPWeb web = properties.OpenWeb();
                           web.AllowUnsafeUpdates = true;
                           SPDocumentLibrary olist = web.Lists["NewLibList"] as SPDocumentLibrary;
                           String url = olist.RootFolder.ServerRelativeUrl.ToString();
                           SPFile file = null;
                           file = web.GetFile(olist.DocumentTemplateUrl);
                           if (file != null)
                               SPListItem oItems = properties.ListItem;
                               web.AllowUnsafeUpdates = true;
                               byte[] readStream = file.OpenBinary();
                               SPFile uploadedFile = olist.RootFolder.Files.Add("http://site/subsite/Libraryname/" + properties.ListItemId.ToString() + ".docx", readStream,
    true);
                               SPListItem listitem = uploadedFile.Item;
                               listitem["Firstname"] = oItems["Firstname"];
                               listitem["Lastname"] = oItems["Lastname"];
                               if (uploadedFile.CheckOutType != SPFile.SPCheckOutType.None)
                                   uploadedFile.CheckIn(string.Empty);
                               listitem.Update();
                               uploadedFile.Update();
                               web.AllowUnsafeUpdates = false;
                       catch (Exception ex)
                           EventLog.WriteEntry(EventLogName, ex.Message, EventLogEntryType.Error);

    Hi,
    Please try to use the code below:
    SPSecurity.RunWithElevatedPrivileges(delegate()
    try
    string TemplateUrl = string.Empty;
    SPWeb web = properties.OpenWeb();
    web.AllowUnsafeUpdates = true;
    SPDocumentLibrary olist = web.Lists["NewLibList"] as SPDocumentLibrary;
    String url = olist.RootFolder.ServerRelativeUrl.ToString();
    SPFile file = null;
    file = web.GetFile(olist.DocumentTemplateUrl);
    if (file != null)
    SPListItem oItems = properties.ListItem;
    web.AllowUnsafeUpdates = true;
    Stream readStream = file.OpenBinaryStream(); //file is SPFile type
    SPFile uploadedFile = olist.RootFolder.Files.Add("http://site/subsite/Libraryname/" + properties.ListItemId.ToString() + ".docx", readStream, true);
    uploadedFile.CheckOut();
    SPListItem listitem = uploadedFile.Item;
    listitem["Firstname"] = oItems["Firstname"];
    listitem["Lastname"] = oItems["Lastname"];
    listitem.Update();
    uploadedFile.Update();
    uploadedFile.CheckIn(string.Empty);
    web.AllowUnsafeUpdates = false;
    catch (Exception ex)
    EventLog.WriteEntry(EventLogName, ex.Message, EventLogEntryType.Error);
    If the issue still exists, I suggest you dubug your code and check whether line of code error.
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • How get all photos from photo streams without iPhoto

    Hi to make A long story short, I lost a Hard Drive with iPhoto on it... Including all my baby's pics ... However I can still see them in the photo streams on my idevices.. First off without that Mac how can just grab all the photos off photo stream without iPhoto?
    Secondly, if I can install iPhoto on another machine or drive will that help or hurt me? Will all the photos show up under my Apple ID and can I just copy them or am I running any risk of deleting the streams?
    Is my only option to copy photos from photo stream a few at a time? And does that not repush them back up to the stream and erase older photos?
    Thank you for any help!!
    Yes I know I am a complete idiot for not backing up or using online backup service... 

    If you create a new library on another Mac, set its Photo Stream preferences to
    and log into your iCloud account on that Mac and enable Photo Stream,  the Photo Stream photos will automatically be imported into the new library. It can take a while depending on how many photos are in the stream.
    When you're done log out of your iCloud account and copy the library to a flash drive or DVD (if small enought) till you get your new drive. 
    OT

  • Can we use 0INFOPROV as a selection in Load from Data Stream

    Hi,
    We have implemented BW-SEM BPS and BCS (SEM-BW - 602 and BI 7 ) in our company.
    We have two BPS cubes for Cost Center and Revenue Planning and we have Actuals Data staging cube, we use 0SEM_BCS_10 to load actuals.
    We created a MultiProvider on BPS cubes and Staging cube as a Source Data Basis for BCS.
    Issue:
    When loading plan data or Actuals data into BCS (0BCS_C11) cube using Load from Data Stream method, we have performance issue, We automated load process in a Process Chain. Some times it take about 20 hrs for only Plan data load for 3 group currencies and then elimination tasks.
    What I noticed is, (for example/) when loading Plan data, system is also reading Actuals Cube which is not required, there is no selection available in Mapping or selection tab where I can restrict data load from a particular cube.
    I tried to add 0INFOPROV into databasis but then it doen't show up as selection option in the data collection tasks.
    Is there a way where I can restrict data load into BCS using this load option and able to restrict on cube I will be reading data from ?
    I know that there is a filter Badi available, but not sure how it works.
    Thanks !!
    Naveen Rao Kattela

    Thanks Eugene,
    We do have other characteristics like Value Type (10 = Actual and 20 = Plan) and Version (100 = USD Actual and 200 = USD Plan), but when I am loading data into BCS using Load from Data Stream method, the request goes to all the underlying cubes, which in my case are Planning cubes and Actual Cube, but I don't want request to goto Actual Cube when I am running only Plan load. I think its causing some performance issue.
    For this reason I am thinking if I can use 0INFOPROV as we use in Bex queries to filter the InfoProvider so that the data load performance will improve. 
    I was able to to bring in 0INFOPROV into DataBasis by adding 0INFOPROV  in the characteristics folder used by the Data Basis.
    I am able to see this InfoObject Data Stream Fileds tab. I checked marked it to use it in the selection and regenerated the databasis.
    I was expecting that now this field would be available for selection in data collection method, but its not.
    So If its confirmed that there is no way we can use 0INFOPROV as a selection then I would suggest my client for a redesign of the DataBasis it self.
    Thanks,
    Naveen Rao Kattela

  • How do I create a shared photo stream?

    I see discussions regarding shared photo streams - all pertaining to issues with existing shared photo streams.  I don't see anything that provides instructions on how to create a shared photo stream.  How is this accomplished?  And how do I allow someone access to my shared photo stream?

    If you're creating it from iPhoto on your Mac this screenshot describes how;
    OT

  • How to download 'all photos at a time' from shared stream?

    I have a photo stream shared album (with 120 pictures) on icloud.  This is shared from iPhone.  I opened the link on my mac/windows in the browser.  Now, how to download 'all photos at a time' from shared stream?  I don't want to download each photo at a time.  There are 100s of photos to download.  I can't open one photo at a time and keep downloading them separately.  There should be a way to download all photos from a shared stream.  Please let me know how you are dealing with this?

    1.you need create a dba user in your database
    2.you can run the script as command
    eg. use PL/sql developer ->new command window->open script-> run.

  • Aperture photos from Photo Stream not syncing in iTunes

    Hi
    I am running Aperture 3.4.3 on an iMac running 10.8.2.  I have Photo Stream enabled.  When I open Aperture, it downloads all the recent photos from Photo Stream and puts them in to one or more automatically created projects called something like "Mar 2013 Photo Stream".  As I understand it, Aperture is copying the photos from Photo Stream to these new projects, so when Photo Stream eventually deletes the photos (say because I reach the 1000 photo limit), the downloaded versions in Aperture won't affected.  So far, so good.
    Because the new projects in Aperture start with the month name, I have taken to renaming these folders to something like "2013 03 March Photo Stream", and you can then sort them alphabetically.  This might be red herring though.
    When I open iTunes and connect my iPhone, I have selected to sync photos from all Events in the last 12 months.  This should include all the projects that were created in Aperture.  This is where I hit the problem.  Some of the projects sync just fine.  Others do not.  When they don't sync, 2 things happen:
    1. The Events don't appear on the iPhone
    2. When I look in iTunes, all the affected Events have the same item count.  The item count is correct for one project, but not the others.  So, for example, I have 4 projects at the moment that won't sync, and all show in iTunes with an item count of 1.  Only one project actually contains 1 photo, the rest have many more. 
    I have tried all sorts of things in Aperture, such as rebuilding the data, deleting the iPod Photo Cache etc.
    Does anyone have any idea?
    Thanks.

    As far as I can tell, my problems have been caused by me renaming the automatic import projects in Aperture.  I did notice that Aperture kept creating new empty projects for the same month. 
    This solution from Jannem1970, posted on this thread https://discussions.apple.com/thread/3585677?start=0&tstart=0, seems to have done the trick for me.
    - turn off automatic import for Photo Stream;
    - identify 'the ghost'-projectfolders, select and delete them;
    - close Aperture (this saves the current setting and condition of your library);
    - open Aperture again;
    - turn on automatic import for Photo Stream.

  • HT4890 how to move photos from Photo Stream to existing albums

    iCloud sends photos to my iMac and iPad from my iPhone (or from my iMac to my iPhone & iPad) to the Photo Stream folder in Photos in ech device.  I want to move those photos from the Photo Stream folder to individual albums.  Can this be done?  If I move the photos from the Photo Stream folder on my iMac to individual albums, will they flow to the album on my iPad and iPhone? 

    Welcome to the Apple Community.
    If you move them to albums in iPhoto on your Mac, you'll need to choose those albums to sync with your devices from the photo tab in iTunes when you connect the device.
    Alternatively, you can create albums from photostream photos on your device. Select the photo sheet screen in photostream on the device, tap the rectangle with an arrow in it, tap the photos you which to add to a new album and choose the 'save' button. Choose from new or existing album or camera roll.

  • Importing photos from photo stream

    Under iphoto, it used to be that photos would be pulled down from photo stream and an album for the month would be auto generated, housing all of the photos for that month that were imported from photo stream.
    Under the new photos app, I see the current month (April 2015) but it's not updating with any new photos.
    When I look at my photo stream (the main fire hose), my photos show there - just not in the auto-generated folder.
    When I pull back and look at the April 2015 folder, it is housed under "iPhoto albums" ...
    My question is this:
    Is this feature now retired?  Do I now have to manually create these monthly folders?
    Differences between iPhoto and the Photos app do not exactly seem to be spelled out.

    I'm also trying to figure some of this out... looking to migrate from Aperture.
    When migrating your old library to Photos, your "April 2015" photo stream was converted to a Photos "album." This, along with your other iPhoto albums (Projects in Aperture) were placed in the "iPhoto albums" folder.
    It doesn't seem that Photos creates new albums for Photo Streams. These photos are all pulled into the one "My Photo Stream" which seems to be a "smart" album.

  • Recently chgd Apple ID and PW.  After update all photos were gone from Photo Stream.  How do I get back?

    Recently updated Apple ID and PW.  After change, all the photos were gone from Photo Stream.  How do I get them back?

    Did you create these notes in the iPad notes App ... I assume?
    This support article will explain how you can restore from a backup - which is what you have to do in order to have any chance of recovering your note.
    How to backup and restore from a backup
    http://support.apple.com/kb/HT1766
    But you have to remember, that you will lose any of the notes that you have taken since the date of the last backup. If you synced your iPad last week, then you will lose a whole week of current notes - or whatever notes you have created since your last backup. When you restore from a backup - you restore everything in that backup onto the iPad - that was on the iPad on the time and date of the backup.
    If you backup every day, then all of your notes should be recoverable from the backup - except for any notes that you took since you last backed up. There is no foolproof way to recover everything once you start taking more notes or creating new documents or whatever that you do in an app unless you are syncing those notes with iCloud and backing up all of the time or unless the app is set to sync with iCloud as you work on the files - like in Pages, Numbers or Keynote - Apple's iWorks apps.
    If you decide to restore from an iTunes backup you should turn off at sync before you try restoring because iTunes will want to backup your iPad right away when you plug it in and you will lose your old or last backup.

  • How risk is to add photos from 'Photo Stream'-

    How risk is to add photos from ‘Photo Stream’ direct to an album on iPad without ‘save to camera roll’ first?… sometimes it works sometimes not. I’m confused.

    I got it… Select all photos from an album, then ‘share’ to iCloud… create a ‘Stream Name’ and email me… Is this the best way? I think it’s great… I didn’t get about the iTunes sync, I’m afraid, I already lost photos in that way…
    thanks

  • Downloading from photo stream

    How do I download photos from a friend's photo stream?

    Have your friend create a shared photo stream which will then be on both of your devices.
    http://support.apple.com/kb/ph2605

Maybe you are looking for

  • 13" Macbook Pro with retina or MacBook Air?

    Hello All, This is my first post to this forum and I need an advice for buying my first MacBook ever. The time has come that I have decided to invest into a Mac and have always been a PC user until now. I was planning to buy the 13" 256GB version (15

  • With the upgrade to Acrobat Pro 9.4.6 I can no longer create a pdf from a document.

    I am using Window XP, Office 2007 Professional.  When the upgrade occurred, I lost the functionallity of creating a pdf from Publisher.  I go through the print, select Adobe PDF and then print.  Sometimes it looks like it is creating a pdf and then o

  • Officejet Pro 8620 will not print old documents, only newly created ones

    When I use the driver designed for the printer I can only print documents (Word, Excel, and Publish 2007) that are new, as long as I have not copied and pasted or inserted sheets from previously created documents.  It will not print any Outlook 2007

  • Applet to Applet communication between two seperate threads and jsp pages

    Hi, have two java applets running on two separate jsp pages. I am trying to have one applet talk to the other applet. I have tried putting the applets in a static hashtable, but I found out (through trial and error) that the memory is not shared betw

  • [SOLVED] Kernel bug? Need help soon!

    After a reboot my arch linux install wont log in anymore... When I enter my username and password at the prompt I get a flash of a screen and then the login prompt again, if I type in my username and such again it doesn't do anything... It just sits