Subversion Repositories XServices

Rev

Rev 150 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 150 Rev 196
Line 13... Line 13...
13
 *   See the License for the specific language governing permissions and
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
14
 *   limitations under the License.
15
 */
15
 */
16
package net.brutex.emitter;
16
package net.brutex.emitter;
Line 17... Line -...
17
 
-
 
18
import java.io.BufferedReader;
-
 
19
import java.io.IOException;
-
 
20
import java.io.InputStreamReader;
-
 
21
 
17
 
22
import org.apache.http.HttpEntity;
18
import org.apache.http.HttpEntity;
23
import org.apache.http.HttpResponse;
19
import org.apache.http.HttpResponse;
24
import org.apache.http.client.ClientProtocolException;
20
import org.apache.http.client.ClientProtocolException;
25
import org.apache.http.client.entity.EntityBuilder;
21
import org.apache.http.client.entity.EntityBuilder;
26
import org.apache.http.client.methods.HttpPost;
22
import org.apache.http.client.methods.HttpPost;
27
import org.apache.http.impl.client.CloseableHttpClient;
23
import org.apache.http.impl.client.CloseableHttpClient;
28
import org.apache.http.impl.client.HttpClients;
-
 
29
import org.apache.http.util.EntityUtils;
24
import org.apache.http.impl.client.HttpClients;
Line -... Line 25...
-
 
25
import org.apache.log4j.Logger;
-
 
26
 
-
 
27
import java.io.BufferedReader;
-
 
28
import java.io.IOException;
30
import org.apache.log4j.Logger;
29
import java.io.InputStreamReader;
31
 
30
 
32
/**
31
/**
33
 * Construct a HTTP POST and send it.
32
 * Construct a HTTP POST and send it.
34
 *
33
 *
Line 50... Line 49...
50
	 */
49
	 */
51
	public SimpleHttpEvent(String url, String soapBody) {
50
	public SimpleHttpEvent(String url, String soapBody) {
52
		this.url = url;
51
		this.url = url;
53
		this.soapBody = soapBody;
52
		this.soapBody = soapBody;
54
	}
53
	}
55
	
54
 
56
	/**
55
	/**
57
	 * Send soap.
56
	 * Send soap.
58
	 *
57
	 *
59
	 * @param url the url
-
 
60
	 * @param soapBody the soap body
58
	 * @param isDropResponse show interest in response or not
61
	 * @throws ClientProtocolException the client protocol exception
59
	 * @throws ClientProtocolException the client protocol exception
62
	 * @throws IOException Signals that an I/O exception has occurred.
60
	 * @throws IOException             Signals that an I/O exception has occurred.
63
	 */
61
	 */
64
	public void sendSoap(boolean isDropResponse) throws ClientProtocolException, IOException {
62
	public void sendSoap(boolean isDropResponse) throws ClientProtocolException, IOException {
65
		long start = System.currentTimeMillis();
63
		long start = System.currentTimeMillis();
66
		HttpPost post = new HttpPost(url);
64
		HttpPost post = new HttpPost(url);
67
        post.addHeader("Accept" , "text/xml");
65
		post.addHeader("Accept", "text/xml");
-
 
66
		post.addHeader("Content-Type", "text/xml; charset=utf-8");
68
        post.addHeader("SOAPAction","");
67
		post.addHeader("SOAPAction", "");
69
        EntityBuilder entitybuilder = EntityBuilder.create();
68
		EntityBuilder entitybuilder = EntityBuilder.create();
70
        entitybuilder.setContentEncoding("UTF-8");
69
		entitybuilder.setContentEncoding("UTF-8");
71
        entitybuilder.setText(soapBody);
70
		entitybuilder.setText(soapBody);
72
        HttpEntity entity = entitybuilder.build();		           
71
		HttpEntity entity = entitybuilder.build();
73
        post.setEntity(entity);
72
		post.setEntity(entity);
74
        
73
 
75
        CloseableHttpClient httpclient = HttpClients.createDefault();
74
		CloseableHttpClient httpclient = HttpClients.createDefault();
76
        HttpResponse r = httpclient.execute(post);
75
		HttpResponse r = httpclient.execute(post);
77
        logger.debug("Sending event to ALF event manager");
76
		logger.debug("Sending event to ALF event manager");
78
        if(! isDropResponse) {
77
		if (!isDropResponse) {
79
			HttpEntity e = r.getEntity();
78
			HttpEntity e = r.getEntity();
80
			StringBuilder sb = new StringBuilder();
79
			StringBuilder sb = new StringBuilder();
81
			BufferedReader in = new BufferedReader(new InputStreamReader(e.getContent()));
80
			BufferedReader in = new BufferedReader(new InputStreamReader(e.getContent()));
82
			String s;
81
			String s;
83
			while( (s=in.readLine()) != null) {
82
			while( (s=in.readLine()) != null) {