Thank you for your quick answer. I followed your peudo code:
NormalizedMessage nm = jbiCtx.getMessageExchange().createMessage();
Document doc = createNewDocument(); // I created new document using DocumentBuilderFactory
Element jbiMessageWrapper = WrapperUtil.createJBIMessageWrapper(doc, new QName("{
http://invoiceanalyzer.se.esb.mycompany.org/InvoiceAnalyzer/}InvoiceAnalyzerOperationResponse"), null);
doc.appendChild(jbiMessageWrapper);
Element jbiPart = WrapperUtil.createJBIWrappedPart(doc, doc.createTextNode("part1"));
jbiMessageWrapper.appendChild(jbiPart);
DataHandler dh = new DataHandler(ds);
String cid = WrapperUtil.createXopCid();
nm.addAttachment(cid, dh);
Element xopIncludeElem = doc.createElementNS("
http://www.w3.org/2004/08/xop/include", "xop:Include"); //I hardcoded namespace URI because
WrapperUtil.XOP_NAMESPACE has private acces
jbiPart.appendChild(xopIncludeElem);
DOMSource src = new DOMSource(jbiMessageWrapper);
nm.setContent(src);
Now my problem is that I do not know if I correctly created jbiMessageWrapper and jbiPart because I am getting error
BPJBI-6012: Exception occurred while processing the response for message exchange with id 270480781624089-9570-134767950393060035 error is BPJBI-6032: Could not find the messageType definition {
http://invoiceanalyzer.se.esb.mycompany.org/InvoiceAnalyzer/}InvoiceAnalyzerOperationResponse, specified by the type attribute in jbi:message element.
How do I get Qname from my wsdl? Sorry if I am missing some knowledge because I am quite new in jbi and openesb
Thanks
Marian
On Fri, Nov 6, 2009 at 3:07 AM, Girish Patil-2 [via OpenESB Users]
<[hidden email]> wrote:
Psuedo code might look like below.
NormalizedMessage nm = jbiCtx.getMessageExchange().createMessage();
Document currDoc = createNewDocument(); /
//Create JBI wrapper message and part elements.
Element jbiMessageWrapper = WrapperUtil.createJBIMessageWrapper(); //See [1] below
currDoc.appendChild(jbiMessageWrapper);
Element jbiPart = WrapperUtil.createJBIWrappedPart(); //See [1] below
jbiMessageWrapper.appendChild(jbiPart);
// Create DataHandler and add it as attachement
DataHandler dh = new DataHandler(ds);
String cid = WrapperUtil.createXopCid(); // See [1] below
nm.addAttachment(cid, dh);
//Create xop:include element append to JBI part element
Element xopIncludeElem = doc.createElementNS(WrapperUtil.XOP_NAMESPACE, "xop:Include");
xopIncludeElem.setAttribute("href", cid);
jbiPart.appendChild(xopIncludeElem);
DOMSource src = new DOMSource(jbiMessageWrapper);
nm.setContent(src);
[1] see methods createXopCid,
createJBIMessageWrapper and createJBIWrappedPart
http://fisheye5.atlassian.com/browse/~raw,r=1.8/open-jbi-components/ojc-core/component-common/component/src/com/sun/jbi/nms/wsdl11wrapper/util/WrapperUtil.java
[hidden email] wrote:
Hi,
I am trying to generate binary file in POJO SE and send it to file-bc to
write it on harddisk.
However I have troubles with adding this generated file as part1 of an
attachment into NormalizedMessage, file bc does not recognize it.
How do you properly create binary attachment and address it in message
payload?
My code in POJO is something like this:
...
NormalizedMessage nm = jbiCtx.getMessageExchange().createMessage();
FileBCDataSource ds = FileBCDataSource(myInputStream, "part1");
DataHandler dh = new DataHandler(ds);
//here should be nm.setContent(), but I do not how to insert reference to my
attachment
nm.addAttachment(dh.getName(), dh);
nm.setProperty("org.glassfish.openesb.file.outbound.filename", myFileName);
return nm;
Method addAttachment has first parameter cid which is unique identifier of
an attachment, but i do not know how to generate it correctly.
I am able to write file with specified myFileName but it has 0 bytes. I know
that I could write it to filesystem right from my POJO, but that is not what
I want (later I would like not to write in on harddisk, but for example
write this file to database trought bpel process and/or database bc etc.).
Please could you give me an advice for creating NormalizedMessage with
binary attachment?
Thank you.
Marian
--
Marian Bystrican
ICQ: 287555380
[hidden email]