<commit_before>package org.ow2.choreos.chors.context;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;

public class SoapContextSender implements ContextSender {
	
	@Override
	public void sendContext(String serviceEndpoint, 
			String partnerRole, String partnerEndpoint) throws ContextNotSentException {
		
		try {
			
	        SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
	        SOAPConnection connection = sfc.createConnection();
	
	        MessageFactory mf = MessageFactory.newInstance();
	        SOAPMessage sm = mf.createMessage();
	
	        SOAPEnvelope envelope = sm.getSOAPPart().getEnvelope();
	        envelope.addNamespaceDeclaration("chor", "http://choreos.ow2.org/");
	        
	        SOAPHeader sh = sm.getSOAPHeader();
	        SOAPBody sb = sm.getSOAPBody();
	        sh.detachNode();
	        QName bodyName = new QName("setInvocationAddress");
	        SOAPBodyElement bodyElement = sb.addBodyElement(bodyName);
	        bodyElement.setPrefix("chor");
	        
	        QName role = new QName("arg0");
	        SOAPElement quotation1 = bodyElement.addChildElement(role);
	        quotation1.addTextNode(partnerRole);
	
	        QName address = new QName("arg1");
	        SOAPElement quotation2 = bodyElement.addChildElement(address);
	        quotation2.addTextNode(partnerEndpoint);
	
	        URL endpoint = new URL(serviceEndpoint);
	        connection.call(sm, endpoint);
		
		} catch (Exception e) {
			throw new ContextNotSentException(serviceEndpoint, partnerRole, partnerEndpoint);
		}
	}

}
<commit_msg>removing ending slash from uri<commit_after>package org.ow2.choreos.chors.context;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;

public class SoapContextSender implements ContextSender {
	
	@Override
	public void sendContext(String serviceEndpoint, 
			String partnerRole, String partnerEndpoint) throws ContextNotSentException {
		
		try {
			
	        SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
	        SOAPConnection connection = sfc.createConnection();
	
	        MessageFactory mf = MessageFactory.newInstance();
	        SOAPMessage sm = mf.createMessage();
	
	        SOAPEnvelope envelope = sm.getSOAPPart().getEnvelope();
	        envelope.addNamespaceDeclaration("chor", "http://choreos.ow2.org/");
	        
	        SOAPHeader sh = sm.getSOAPHeader();
	        SOAPBody sb = sm.getSOAPBody();
	        sh.detachNode();
	        QName bodyName = new QName("setInvocationAddress");
	        SOAPBodyElement bodyElement = sb.addBodyElement(bodyName);
	        bodyElement.setPrefix("chor");
	        
	        QName role = new QName("arg0");
	        SOAPElement quotation1 = bodyElement.addChildElement(role);
	        quotation1.addTextNode(partnerRole);
	
	        QName address = new QName("arg1");
	        SOAPElement quotation2 = bodyElement.addChildElement(address);
	        quotation2.addTextNode(partnerEndpoint);
	        
	        if (serviceEndpoint.trim().endsWith("/"))
	        	serviceEndpoint = serviceEndpoint.substring(0, serviceEndpoint.length() - 1);
	
	        URL endpoint = new URL(serviceEndpoint);
	        connection.call(sm, endpoint);
		
		} catch (Exception e) {
			throw new ContextNotSentException(serviceEndpoint, partnerRole, partnerEndpoint);
		}
	}

}

{'fraction_non_alphanumeric': 0.09808371154815936, 'fraction_numerical': 0.0045385779122541605, 'mean_word_length': 3.437360178970917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 20}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1468407', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1113, 'n_words': 216}