There is no difference, that's why it would be nice to use Http Sampler.
See current code for generation of stream, I would need at some step to do
this :
writer.writeMessage(message, outputStream that I would get from HTTPClient);
----------------------------------------------------------------------------------------------------------------------------------
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.Header;
import org.apache.james.mime4j.dom.MessageWriter;
import org.apache.james.mime4j.dom.Multipart;
import org.apache.james.mime4j.dom.TextBody;
import org.apache.james.mime4j.field.DefaultFieldParser;
import org.apache.james.mime4j.message.BodyPart;
import org.apache.james.mime4j.message.DefaultMessageWriter;
import org.apache.james.mime4j.message.HeaderImpl;
import org.apache.james.mime4j.message.MessageImpl;
import org.apache.james.mime4j.message.MultipartImpl;
import org.apache.james.mime4j.storage.StorageBodyFactory;
public class TestMime4j {
public static void main(String[] args) throws IOException,
MimeException {
MessageImpl message = new MessageImpl();
// Date and From are required fields
// Message-ID should be present
//message.createMessageId("machine.example");
Multipart multipart = new MultipartImpl("related");
// first part is text/plain
StorageBodyFactory bodyFactory = new StorageBodyFactory();
BodyPart textPart = createTextPart(bodyFactory, "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"></soap:Envelope>");
multipart.addBodyPart(textPart);
// setMultipart also sets the Content-Type header field
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("type", "text/xml");
map.put("start", "<[email protected]>");
map.put("start-info", "text/xml");
message.setMultipart(multipart, map);
//message.setBody(mul, "application/xop+xml", map);
// header.addField(
DefaultFieldParser.parse("type=application/xop+xml"));
// message.setHeader(header);
// 4) print message to standard output
MessageWriter writer = new DefaultMessageWriter();
writer.writeMessage(message, System.out);
// 5) message is no longer needed and should be disposed of
message.dispose();
}
/**
* Creates a text part from the specified string.
* @throws MimeException
*/
private static BodyPart createTextPart(StorageBodyFactory bodyFactory,
String text) throws MimeException {
// Use UTF-8 to encode the specified text
TextBody body = bodyFactory.textBody(text, "UTF-8");
Header header = new HeaderImpl();
header.addField(
DefaultFieldParser.parse("Content-ID: <
[email protected]>"));
// Create a text/plain body part
BodyPart bodyPart = new BodyPart();
bodyPart.setHeader(header);
Map<String, String> map = new HashMap<String, String>();
map.put("type", "text/xml");
map.put("charset", "UTF-8");
bodyPart.setBody(body, "application/xop+xml", map);
bodyPart.setContentTransferEncoding("8bit");
return bodyPart;
}
}
On Sat, Jul 27, 2013 at 2:13 PM, sebb <[email protected]> wrote:
> On 27 July 2013 13:02, Philippe Mouawad <[email protected]>
> wrote:
> > Hello,
> > I have started implementing Soap With Attachment (MTOM+XOP) and I was
> > wondering what's the best option for GUI.
> >
> > 1) Use HttpSampler. The problem is that it is already very rich and I
> don't
> > know how user could tell he want's SOAP with Attachment.
> >
> > 2) Create a new GUI but it would be very close from Http Sampler one and
> I
> > don't want to duplicate code
> >
> > What's your opinions ?
>
> What are the differences from standard HTTP?
>
> > Regards
> > Philippe
>
--
Cordialement.
Philippe Mouawad.