1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments;
14
15 import com.eviware.soapui.impl.wsdl.WsdlRequest;
16 import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
17
18 import javax.activation.DataSource;
19 import java.io.ByteArrayInputStream;
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.io.OutputStream;
23
24 /***
25 * DataSource for an existing WsdlRequest
26 *
27 * @author ole.matzura
28 */
29
30 public class WsdlRequestDataSource implements DataSource
31 {
32 private final WsdlRequest wsdlRequest;
33 private final String requestContent;
34 private final boolean isXOP;
35
36 public WsdlRequestDataSource(WsdlRequest wsdlRequest, String requestContent, boolean isXOP)
37 {
38 this.wsdlRequest = wsdlRequest;
39 this.requestContent = requestContent;
40 this.isXOP = isXOP;
41 }
42
43 public String getContentType()
44 {
45 SoapVersion soapVersion = wsdlRequest.getOperation().getInterface().getSoapVersion();
46
47 if( isXOP )
48 {
49 return AttachmentUtils.buildRootPartContentType( wsdlRequest.getOperation().getName(), soapVersion);
50 }
51 else
52 {
53 return soapVersion.getContentType() + "; charset=UTF-8";
54 }
55 }
56
57 public InputStream getInputStream() throws IOException
58 {
59 byte[] bytes = requestContent.getBytes( "UTF-8");
60 return new ByteArrayInputStream( bytes);
61 }
62
63 public String getName()
64 {
65 return wsdlRequest.getName();
66 }
67
68 public OutputStream getOutputStream() throws IOException
69 {
70 return null;
71 }
72 }