1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.submit.filters;
14
15 import org.apache.commons.httpclient.URI;
16
17 import com.eviware.soapui.impl.wsdl.WsdlInterface;
18 import com.eviware.soapui.impl.wsdl.WsdlRequest;
19 import com.eviware.soapui.impl.wsdl.submit.RequestFilter;
20 import com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpRequestTransport;
21 import com.eviware.soapui.impl.wsdl.submit.transports.http.TimeablePostMethod;
22 import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
23 import com.eviware.soapui.model.iface.SubmitContext;
24 import com.eviware.soapui.settings.HttpSettings;
25
26 /***
27 * RequestFilter that adds SOAP 1.1 specific headers
28 *
29 * @author Ole.Matzura
30 */
31
32 public class SoapHeadersRequestFilter implements RequestFilter
33 {
34 public void filterRequest(SubmitContext context, WsdlRequest wsdlRequest)
35 {
36 TimeablePostMethod postMethod = (TimeablePostMethod) context.getProperty( BaseHttpRequestTransport.POST_METHOD );
37
38 WsdlInterface wsdlInterface = (WsdlInterface) wsdlRequest.getOperation().getInterface();
39 String strURL = wsdlInterface.getEndpointURL(wsdlRequest.getEndpoint());
40 strURL = PropertyExpansionRequestFilter.expandProperties( context, strURL );
41 try
42 {
43 postMethod.setURI(new URI(strURL, wsdlRequest.getSettings().getBoolean( HttpSettings.ENCODED_URLS )));
44 }
45 catch ( Exception e)
46 {
47 e.printStackTrace();
48 }
49
50
51 String encoding = wsdlRequest.getEncoding();
52
53 SoapVersion soapVersion = wsdlInterface.getSoapVersion();
54 postMethod.setRequestHeader( "Content-Type", soapVersion.getContentTypeHttpHeader( encoding ));
55
56
57 String soapAction = wsdlRequest.getOperation().getAction();
58 if (soapAction == null || soapAction.length() == 0)
59 {
60 soapAction = "\"\"";
61 }
62 else
63 {
64 soapAction = "\"" + soapAction + "\"";
65 }
66
67 postMethod.setRequestHeader("SOAPAction", soapAction);
68
69 }
70 }