G
Guenter Dannhaeuser
Hi,
I have a webservice using Jena on some RDF/XML data resulting in a
com.hp.hpl.jena.rdf.model.Model which I´d like to return to the client
as RDF/XML-Document.
com.hp.hpl.jena.rdf.model.Model has a method "write" to turn the Model
into RDF/XML and write it to an OutputStream.
First idea: return the XML in a string:
//webservice
public String lookup(String param1, String param2) {
Model mymodel = ModelFactory.createDefaultModel();
//do something ...
ByteArrayOutputStream os = new ByteArrayOutputStream();
mymodel.write(os, "RDF/XML-ABBREV");
return os.toString();
}
.... this works ok on the server-side
(System.out.println(os.toString()) = document as expected),
but on client-side all I get is:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
</rdf:RDF>
(first xmlns:rdf and all nodes missing)
//the client:
//...
myService service = new myServiceLocator();
my_PortType stub = service.getMyMethod();
System.out.println(stub.lookup("astring", "anotherstring"));
//...
Next idea: put it in an attachment:
//webservice
//...
//do something ...
MessageContext context = MessageContext.getCurrentContext();
Message response = context.getResponseMessage();
response.getAttachmentsImpl().setSendType(Attachments.SEND_TYPE_DIME);
DataHandler dh = new DataHandler(baos.toString(), "???");
AttachmentPart attachment = response.createAttachmentPart(dh);
attachment.setContentId("attachment");
response.addAttachmentPart(attachment);
problems: how to get the DataHandler dh? how to unpack the attachment
on client-side?
Thanks a lot for all help.
I have a webservice using Jena on some RDF/XML data resulting in a
com.hp.hpl.jena.rdf.model.Model which I´d like to return to the client
as RDF/XML-Document.
com.hp.hpl.jena.rdf.model.Model has a method "write" to turn the Model
into RDF/XML and write it to an OutputStream.
First idea: return the XML in a string:
//webservice
public String lookup(String param1, String param2) {
Model mymodel = ModelFactory.createDefaultModel();
//do something ...
ByteArrayOutputStream os = new ByteArrayOutputStream();
mymodel.write(os, "RDF/XML-ABBREV");
return os.toString();
}
.... this works ok on the server-side
(System.out.println(os.toString()) = document as expected),
but on client-side all I get is:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
</rdf:RDF>
(first xmlns:rdf and all nodes missing)
//the client:
//...
myService service = new myServiceLocator();
my_PortType stub = service.getMyMethod();
System.out.println(stub.lookup("astring", "anotherstring"));
//...
Next idea: put it in an attachment:
//webservice
//...
//do something ...
MessageContext context = MessageContext.getCurrentContext();
Message response = context.getResponseMessage();
response.getAttachmentsImpl().setSendType(Attachments.SEND_TYPE_DIME);
DataHandler dh = new DataHandler(baos.toString(), "???");
AttachmentPart attachment = response.createAttachmentPart(dh);
attachment.setContentId("attachment");
response.addAttachmentPart(attachment);
problems: how to get the DataHandler dh? how to unpack the attachment
on client-side?
Thanks a lot for all help.