Hi,
I'm writing an Xfire webservice that is accessed by an existing Axis(1)
client.
Unfortunatelly, the client is having problems with my service's response.
Maybe there is someone out there that has an idea what's wrong with my
service?
Is it possible that multiRefs are the problem? (I know, it's a kind of a
crystal ball question)
The client expects some attachements to the message and does the following
code to process the message's attachements
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.SAXException;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.Message;
import org.apache.axis.attachments.Attachments;
import org.apache.axis.attachments.IncomingAttachmentStreams;
protected void parseAttachment(Attributes attributes, DeserializationContext
context) throws SAXException {
try {
String href = ((AttributesImpl)attributes).getValue("href");
if (href.regionMatches(0, "cid:", 0, 4)) {
href = href.substring(4);
}
Message message =
context.getMessageContext().getCurrentMessage();
Attachments attachments = message.getAttachmentsImpl();
IncomingAttachmentStreams streams =
attachments.getIncomingAttachmentStreams();
IncomingAttachmentStreams.IncomingAttachmentInputStream current;
byte[] content = null;
byte[] buffer = new byte[ByteBuffer.MIN_BUFFER_SIZE];
int streamsCounter=0;
while((current = streams.getNextStream()) != null) {
streamsCounter++;
String contentID = current.getContentId();
if (contentID == null) {
contentID = current.getHeader("Content-ID");
}
if (contentID != null) {
contentID = contentID.substring(1, contentID.length() - 1);
if (contentID.equals(href) || href.equals("#id2") {
content = (new ByteBuffer(result.getSize())).read(current);
break;
}
}
while(!streams.isReadyToGetNextStream()) {
current.read(buffer, 0, ByteBuffer.MIN_BUFFER_SIZE);
}
}
// ....
}
catch (Exception e) {
throw new SAXException(e);
}
}
}
The custom Type of my Service writes his data as attachement to the message
the following way:
public void writeObject( final Object object, final MessageWriter writer,
final MessageContext context ) throws XFireFault
{
MyObject binary = (MyObject)object;
OutMessage message = context.getOutMessage();
byte[] content = binary.getContent();
ByteDataSource ds = new ByteDataSource(content);
ds.setContentType( binary.getMimetype() );
ds.setName( binary.getFilename() );
DataHandler handler = new DataHandler( ds );
SimpleAttachment attachment = new SimpleAttachment( "1", handler );
Attachments attachments = message.getAttachments();
if( attachments == null )
attachments = new JavaMailAttachments();
attachments.addPart( attachment );
message.setAttachments( attachments );
String contentID = attachment.getId();
attachment.setHeader( "Content-ID", contentID );
MessageWriter contentWriter = writer.getElementWriter( "content" );
contentWriter.getAttributeWriter( "href").writeValue( "cid:" + contentID
);
contentWriter.close();
}
Thanks for any idea...
Rainer
--
View this message in context:
http://www.nabble.com/Xfire-webservice-with-Axis-client-tf3659119.html#a10224089
Sent from the XFire - User mailing list archive at Nabble.com.