[JBossWS] - Re: My WS doesn't send any attachment... why?
by mrostan
Hi Claudio.
Well, I've tested a case very similar to yours, in the same versions (JBoss 4.2.2 with the default JBossWS: 2.0.1 SP2)
I've changed one thing from my previous suggestion, annotate the dummy field with @XmlAttachmentRef:
| public class DocumentsSet {
| @XmlAttachmentRef
| String dummy;
|
| @XmlElement(name="Documents")
| List<Document> documents;
| }
|
The Document class is very similar:
| public class Document {
| public Document() {
| }
|
| public Document(String name, String fileUrl) {
| this.name = name;
| try {
| this.data = new DataHandler(new URL(fileUrl));
| } catch (MalformedURLException exc) {
| exc.printStackTrace();
| }
| }
|
| String name;
|
| @XmlAttachmentRef
| DataHandler data;
| }
|
And it works here, I see a multipart message as the response, I'm using soapUI to invoke it and I can see the attachments in the result also.
So, I believe it should work for you.
Regards,
Martin
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131787#4131787
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131787
16 years, 10 months
[JBossWS] - Re: My WS doesn't send any attachment... why?
by cdc08x
Thank you Martin for your kind reply. I did appreciate it very much but...
Here is the new wrapper class:
| @XmlRootElement(name="Documenti")
| public class DocumentiDataList {
| @XmlMimeType("application/octet-stream")
| protected String dummy;
|
| @XmlElement(name="documenti")
| public List<DocumentoData> documenti;
|
| protected DocumentiDataList() {}
|
| public DocumentiDataList(List<DocumentoData> list) {
| this.dummy = "";
| this.documenti = list;
| }
| }
|
where DocumentoData is:
| @XmlRootElement(name="DocumentoData")
| public class DocumentoData {
| /**
| * Autore del documento.
| */
| @XmlAttribute(required=true)
| public String autore;
|
| /**
| * Data della creazione del documento.
| */
| @XmlAttribute(required=true)
| public Calendar dataCreazione;
|
| /**
| * Numero identificativo (chiave) del documento
| * <br />Deve essere univoco per ogni documento generato, e positivo.
| */
| @XmlElement(required=true)
| public int numeroDocumento;
|
| /**
| * Numero di protocollo del documento (attributo opzionale).
| * <br />Qualora presente, questo attributo deve essere univoco per tutti gli oggetti di questa classe.
| */
| @XmlElement(required=false)
| public Protocollo protocollo;
|
| /**
| * Nome del file.
| */
| @XmlElement(required=true)
| public String nomeFile;
|
| /**
| * Titolo del documento.
| */
| @XmlElement(required=true)
| public String titolo;
|
| /**
| * Descrizione del documento (attributo opzionale).
| */
| @XmlElement(required=false)
| public String descrizione;
|
| /**
| * Contenuto binario del documento (mappato come <em>SwAref</em>, allegato SOAP)
| */
| @XmlAttachmentRef
| public DataHandler file;
|
| // Costruttore richiesto da JAXB: impostandone l'accesso a "protected", si evita la trasposizione in XML-Schema
| protected DocumentoData() {}
|
| /**
| * Costruttore di istanze <code>DocumentoData</code>
| * @param autore Autore del documento
| * @param dataCreazione Data di creazione del documento
| * @param numeroDocumento Numero del documento
| * @param protocollo Protocollo del documento (puÃÂò essere <code>null</code>)
| * @param nomeFile Nome del file
| * @param titolo Titolo del file
| * @param descrizione Descrizione del contenuto (puÃÂò essere una stringa vuota)
| * @param data Handler dei dati fisici del file
| */
| public DocumentoData(String autore, Calendar dataCreazione,
| int numeroDocumento, Protocollo protocollo,
| String nomeFile, String titolo, String descrizione, DataHandler data) {
| this.autore = autore;
| this.dataCreazione = dataCreazione;
| this.numeroDocumento = numeroDocumento;
| this.protocollo = protocollo;
| this.nomeFile = nomeFile;
| this.titolo = titolo;
| this.descrizione = descrizione;
| this.file = data;
| }
| }
|
and this is the SessionBean's WebService method the client calls:
| public DocumentiDataList getDocumentiRichiestaAvvioPratica(int numeroIstanza,
| String settore, String natura)
| throws IllegalArgumentException {
| DocumentoData newDocumentoData = new DocumentoData(
| "Claudio Di Ciccio",
| new GregorianCalendar(),
| 14,
| null,
| "RichiestaAvvio.13.A2.1244.pdf",
| "Richiesta avvio procedimento - Settore Vincolo Idrogeologico - Allargamento pista camionabile",
| "Richiesta avvio procedimento",
| new DataHandler(new FileDataSource("/var/SemplificAZIONE/RichiestaAvvio.13.A2.1244.pdf")));
| List<DocumentoData> returnList = new ArrayList<DocumentoData>(2);
| returnList.add(newDocumentoData);
| returnList.add(newDocumentoData);
| return new DocumentiDataList(returnList);
| }
|
but the response is still:
| HTTP/1.1 200 OK
| Server: Apache-Coyote/1.1
| X-Powered-By: Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)/Tomcat-5.5
| Content-Type: text/xml;charset=UTF-8
| Date: Mon, 25 Feb 2008 09:11:13 GMT
| Connection: close
|
| <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
| <env:Header>
| </env:Header>
| <env:Body>
| <ns2:getDocumentiRichiestaAvvioPraticaResponse xmlns:ns2="http://www.provincia.latina.it/servizi/ws/PraticaStartWS">
| <documentiData>
| <dummy>
| </dummy>
| <documenti dataCreazione="2008-02-25T10:11:13.901+01:00" autore="Claudio Di Ciccio">
| <numeroDocumento>14</numeroDocumento>
| <nomeFile>RichiestaAvvio.13.A2.1244.pdf</nomeFile>
| <titolo>Richiesta avvio procedimento - Settore Vincolo Idrogeologico - Allargamento pista camionabile</titolo>
| <descrizione>Richiesta avvio procedimento</descrizione>
| <file>cid:0-1203930673914-19807859@ws.jboss.org</file>
| </documenti>
| <documenti dataCreazione="2008-02-25T10:11:13.901+01:00" autore="Claudio Di Ciccio">
| <numeroDocumento>14</numeroDocumento>
| <nomeFile>RichiestaAvvio.13.A2.1244.pdf</nomeFile>
| <titolo>Richiesta avvio procedimento - Settore Vincolo Idrogeologico - Allargamento pista camionabile</titolo>
| <descrizione>Richiesta avvio procedimento</descrizione>
| <file>cid:1-1203930673914-32990827@ws.jboss.org</file>
| </documenti>
| </documentiData>
| </ns2:getDocumentiRichiestaAvvioPraticaResponse>
| </env:Body>
| </env:Envelope>
|
I tried it, believe me, but it doesn't work.
Maybe it's because of the version? The running Application Server is:
JBoss AS 4.2.2.GA
with JBossWS / jbossws-native-2.0.1.SP2 bundled,
over Ubuntu Linux 7.10,
with Sun Java JDK 1.5.0_13 as the default JDK/JVM
Thank you very much, once again!!
Best regards,
Claudio
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131759#4131759
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131759
16 years, 10 months
[JBossWS] - Re: My WS doesn't send any attachment... why?
by mrostan
Hi Claudio.
Maybe I was not clear enough, I'm not sure you have tried my solution, so here is an example:
Create a wrapper class, let's say Documentos:
| public class Documentos {
| @XmlMimeType("application/octet-stream")
| private String dummy;
|
| private List<DocumentoData> documentos;
| }
|
It should work, the trick is the annotation in the dummy string, simply put the field, you don't need to use it
Btw, I will upload a patch later, and I will test a case similar to yours, so I expect this problem to be fixed on jbossws 2.0.4 .
Regards,
Martin
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131721#4131721
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131721
16 years, 10 months
[JBossWS] - Re: My WS doesn't send any attachment... why?
by cdc08x
Thank you very much, Martin, for your help!
Sadly, the solutions you suggested me aren't suitable for my case, because the other fields into the DocumentoData class are tightly connected to the DataHandler - that is, it's a design issue: they're all meta-information about the pdf file the DataHandler holds, so the wrapper should wrap a Collection of DocumentoData objects, and not a Collection of DataHandlers "alone"!
I tried to wrap a Collection of DocumentoData instances, but it doesn't work anyway.
On the other hand, the client is not MTOM/XOP enabled, because it's a PHP PEAR::SOAP client.
I think I will have to abandon the idea of putting as attachment the files, then, and use the base64-encoding.
Thank you, anyway!
Best regards,
Claudio
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131696#4131696
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131696
16 years, 10 months
[JBossWS] - Web Services Transactions
by matias.blasi
Hello, I am researching about the web services transactions behaiviour...
I have read the WS-C, WS-AT & WS-BA specifications, and several internet papers, i have the concepts.
Now I am looking for a working sample, to have something runing something to begin from...
I know that Arjuna had an implementation, and it was included in jboss project so far. I understand it is now the jbossts component.
I was trying to run the xts-demo application into the jboss-4.2.2 & jbossts-4.2.2 with no success...
Now I am with jboss-5.0.0-beta4, where is the web services transcation support here? I see only a jbossws component, as a .sar application, but no samples, and nothing seems to provide the web services transaction support...
Can anyone help me? I've put a lot of days in that, and I need a sample to see this feature really working...
Thank you a lot!
Matias Blasi.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131661#4131661
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131661
16 years, 10 months