On 27 July 2013 13:42, Philippe Mouawad <[email protected]> wrote: > On Sat, Jul 27, 2013 at 2:27 PM, sebb <[email protected]> wrote: > >> On 27 July 2013 13:20, Philippe Mouawad <[email protected]> >> wrote: >> > There is no difference, that's why it would be nice to use Http Sampler. >> >> There must be something about the current sampler GUI that is not >> suitable, otherwise surely there would be no need to change anything? >> > > Well I don't see how as a user you can specify you want to do SOAP + > Attachment
Attachments are possible. Headers and parameters are possible. I don't know SOAP so I don't know what would be a sensible GUI to use to create SOAP requests. What exactly needs to be provided to make it easy to generate the SOAP requests? > >> I don't undertstand what you are proposing. >> >> I am working on this : > https://issues.apache.org/bugzilla/show_bug.cgi?id=53628 > > Today how can you implement Soap With Attachment in JMeter ? > From my understanding it's not possible, am I wrong ? No idea; I don't know SOAP well enough. > > >> I don't want the full details of code changes at this point, just some >> idea of what might need to be changed. >> >> > In HttpHC4Impl , the sendPostData would need to be changed , a new > condition testing for Soap with Attachment would use part of the code I > showed below. > HttpSamplerBase#getUseMultipartForPost would need to be changed as for > Soap+Attachment, this condition is also true: > if(HTTPConstants.POST.equals(getMethod()) && (getDoMultipartPost() || > (files.length > 0 && !getSendFileAsPostBody()))) > > > In GUI, we would also need to add an new column for files to upload > specifying the way they are attached, value could be: > - XOP, would use code below, see http://www.w3.org/TR/soap12-mtom/ > - Base64 , would compute a Base64 from attached file, see > http://www.w3.org/TR/SOAP-attachments > - Mime, would use regular attachment (but it's not priority for me), see > http://www.w3.org/TR/SOAP-attachments > > > 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. >> > > > > -- > Cordialement. > Philippe Mouawad.
