Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.paypal.base;
  
  import java.util.HashMap;
  import java.util.Map;
 
 
 
DefaultSOAPAPICallHandler acts as a basic SOAP APICallPreHandler. The interface method returns defaults for HTTP headers which may be an empty java.util.Map. If SOAP:HEADERS are added as headerString property and Namespace (to be added to SOAP:ENVELOPE) as namespace property then DefaultSOAPAPICallHandler returns a String for getPayLoad method that includes place-holders in the form {i} where i = 0, 1, 2.. that can be used by any upper level classes to replace them with appropriate values.
 
 public class DefaultSOAPAPICallHandler implements APICallPreHandler {

XML Namespace provider for SOAP serialization

Author(s):
kjayakumar
 
 	public interface XmlNamespaceProvider {

Return a java.util.Map of XML Namespaces with the entries in the format [prefix] = [namespace]

Returns:
java.util.Map of XML Namespaces
 
 
 	}

XMLNamespaceProvider providing namespaces for SOAP Envelope
 
XMLNS attribute
 
 	private static final String XMLNS_ATTRIBUTE_PREFIX = "xmlns:";

SOAP Envelope qualified for namespace 'http://schemas.xmlsoap.org/soap/envelope/' with prefix soapenv
 
 	private static final String SOAP_ENVELOPE_QNAME = "soapenv:Envelope";

SOAP Header qualified for namespace 'http://schemas.xmlsoap.org/soap/envelope/' with prefix soapenv
 
 	private static final String SOAP_HEADER_QNAME = "soapenv:Header";

SOAP Body qualified for namespace 'http://schemas.xmlsoap.org/soap/envelope/' with prefix soapenv
 
 	private static final String SOAP_BODY_QNAME = "soapenv:Body";

SOAP Envelope Message Formatter String start
 
 	private static final String SOAP_ENV_START = "<" + 
 			+ "soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" {0}>";

SOAP Envelope Message Formatter String end
	private static final String SOAP_ENV_END = "</" +  + ">";

SOAP Header Message Formatter String start
	private static final String SOAP_HEAD_START = "<" + 
">{1}";

SOAP Header Message Formatter String end
	private static final String SOAP_HEAD_END = "</" +  + ">";

SOAP Body Message Formatter String start
	private static final String SOAP_BODY_START = "<" + 
">{2}";

SOAP Body Message Formatter String end
	private static final String SOAP_BODY_END = "</" +  + ">";

Namespace of SOAP Envelope
	private static final String SOAP_ENV_NS = "http://schemas.xmlsoap.org/soap/envelope/";

Sets an implemenation of com.paypal.base.message.XMLMessageSerializer

Parameters:
xmlNamespaceProvider
	public static void setXmlNamespaceProvider(
			XmlNamespaceProvider xmlNamespaceProvider) {
	}

Raw payload from stubs
	private String rawPayLoad;

Header element as String
	private String headerString;

Namespace attributes as String
	private String namespaces;

Map used for to override ConfigManager configurations
	private Map<StringStringconfigurationMap = null;

SOAP API operation name
	private String methodName = null;

BaseAPIContext instance
Instance of com.paypal.base.message.XMLMessageSerializer for SOAP Header

Returns:
the headerString
	public String getHeaderString() {
		return ;
	}

Parameters:
headerString the headerString to set
	public void setHeaderString(String headerString) {
		this. = headerString;
	}

Returns:
the namespaces
	public String getNamespaces() {
		return ;
	}

Parameters:
namespaces the namespaces to set
	public void setNamespaces(String namespaces) {
		this. = namespaces;
	}

DefaultSOAPAPICallHandler acts as the base SOAPAPICallHandler.

Deprecated:
Parameters:
rawPayLoad Raw SOAP payload that goes into SOAP:BODY
namespaces Namespace attributes that should be appended to SOAP:ENVELOPE, this argument can take any valid String value, empty String or NULL. If the value is NULL {0} value is sandwiched between SOAP:HEADER element that can be used for decorating purpose
headerString SOAP header String that should be appended to SOAP:HEADER, this argument can take any valid String value, empty String or NULL. If the value is NULL {1} value is sandwiched between SOAP:HEADER element that can be used for decorating purpose
	public DefaultSOAPAPICallHandler(String rawPayLoadString namespaces,
			String headerString) {
		super();
		this. = rawPayLoad;
		this. = namespaces;
		this. = headerString;
	}

DefaultSOAPAPICallHandler acts as the base SOAPAPICallHandler.

Parameters:
rawPayLoad Raw SOAP payload that goes into SOAP:BODY
namespaces Namespace attributes that should be appended to SOAP:ENVELOPE, this argument can take any valid String value, empty String or NULL. If the value is NULL, {0} value is added to SOAP:ENVELOPE (ex: <soapenv:Envelope {0}>...</soapenv:Envelope) element that can be used for decorating purpose
headerString SOAP header String that should be appended to SOAP:HEADER, this argument can take any valid String value, empty String or NULL. If the value is NULL, {1} is placed between SOAP:HEADER (ex: <soapenv:Header>{1}</soapenv:Header>)element that can be used for decorating purpose
configurationMap java.util.Map used for Dynamic configuration, mandatory parameter
	public DefaultSOAPAPICallHandler(String rawPayLoadString namespaces,
			String headerStringMap<StringStringconfigurationMap) {
		if (configurationMap == null) {
					"configurationMap cannot be null");
		}
		this. = rawPayLoad;
		this. = namespaces;
		this. = headerString;
		this. = SDKUtil.combineDefaultMap(configurationMap);
	}

DefaultSOAPAPICallHandler taking com.paypal.base.message.XMLMessageSerializer instance for SOAP Body part. SOAP Header part is set in BaseAPIContext as Application Header property (The Application Header should be an instance of com.paypal.base.message.XMLMessageSerializer ). Dynamic configuration can be set using the configurationMap property of BaseAPIContext which will take higher precedence than the one set in the Service level. ConfigurationMap is treated as a mandatory parameter picked either from BaseAPIContext configurationMap parameter or configurationMap argument in that order of precedence.

Parameters:
soapBodyContent SOAP Body Serializer
baseAPIContext BaseAPIContext instance
configurationMap ConfigurationMap used for Dynamic configuration
methodName SOAP API operation name
			BaseAPIContext baseAPIContext,
			Map<StringStringconfigurationMapString methodName) {
		Map<StringStringconfigMap = (baseAPIContext != null && baseAPIContext
				.getConfigurationMap() != null) ? baseAPIContext
				.getConfigurationMap() : configurationMap;
		if (configMap == null) {
					"configurationMap cannot be null");
		}
		this. = SDKUtil.combineDefaultMap(configMap);
		this. = baseAPIContext;
		this. = methodName;
		if (baseAPIContext != null) {
			this. = (XMLMessageSerializerbaseAPIContext
		}
		this. = soapBodyContent;
	}
	public Map<StringStringgetHeaderMap() {
		Map<StringStringheadersMap = null;
		if ( != null) {
		}
		if (headersMap == null) {
			headersMap = new HashMap<StringString>();
		}
		// Append HTTP Content-Type text/xml
		return headersMap;
	}
	public String getPayLoad() {
		String payload = null;
		if ( != null) {
			try {
				payload = getSoapEnvelope();
catch (Exception e) {
				throw new RuntimeException("Exception ["
"] in creating PayLoad"e);
			}
else {
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.append(getSoapEnvelopeStart());
			stringBuilder.append(getSoapHeaderStart());
			stringBuilder.append(getSoapHeaderEnd());
			stringBuilder.append(getSoapBodyStart());
			stringBuilder.append(getSoapBodyEnd());
			stringBuilder.append(getSoapEnvelopeEnd());
			payload = stringBuilder.toString();
		}
		return payload;
	}
	public String getEndPoint() {
	}
		return null;
	}
	public void validate() throws ClientActionRequiredException {
		return;
	}
		String envelope = null;
		if ( != null) {
			envelope = MessageFormat.format(,
					new Object[] {  });
else {
			envelope = ;
		}
		return envelope;
	}
		return ;
	}
		String header = null;
		if ( != null) {
			header = MessageFormat.format(new Object[] { null,
else {
			header = ;
		}
		return header;
	}
	private String getSoapHeaderEnd() {
	}
	private String getSoapBodyStart() {
		String body = null;
		if ( != null) {
			body = MessageFormat.format(new Object[] { null,
					null });
else {
		}
		return body;
	}
	private String getSoapBodyEnd() {
	}

	}

		Node envelopeNode = null;
		if ( != null) {
			Node headerContentNode = soapDocument.importNode(
			soapDocument
									.indexOf(':') + 1)).item(0)
					.appendChild(headerContentNode);
		}
		if ( != null) {
			Node bodyContentNode = soapDocument.importNode(
			soapDocument
									.indexOf(':') + 1)).item(0)
					.appendChild(bodyContentNode);
		}
		envelopeNode = soapDocument.getDocumentElement();
		return envelopeNode;
	}

Creates a org.w3c.dom.Document for SOAP Envelope

		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		Document soapDocument = domImpl.createDocument(,
		// Add any namespaces set in XmlNamespaceProvider implementation
		Element soapHeader = soapDocument.createElementNS(,
		Element soapBody = soapDocument.createElementNS(,
		soapDocument.getDocumentElement().appendChild(soapHeader);
		soapDocument.getDocumentElement().appendChild(soapBody);
		return soapDocument;
	}

Adds namespaces to the provided org.w3c.dom.Element

Parameters:
element
	private void setNamespaces(Element element) {
		if (element != null &&  != null) {
entry.getKey().trim(), entry.getValue().trim());
			}
		}
	}

Returns a org.w3c.dom.Node object by parsing the String content of the node

Parameters:
nodeAsString String content of the node
Returns:
org.w3c.dom.Node corresponding the String content
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
	private Node getNode(String nodeAsString)
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
		InputSource inStream = new InputSource();
		inStream.setCharacterStream(new StringReader(nodeAsString));
		Document doc = dBuilder.parse(inStream);
		return doc.getChildNodes().item(0);
	}

Returns the content of the org.w3c.dom.Node object as a String

Parameters:
node org.w3c.dom.Node to be converted to String
Returns:
String representation of the org.w3c.dom.Node
Throws:
javax.xml.transform.TransformerFactoryConfigurationError
javax.xml.transform.TransformerException
	private String nodeToString(Node node)
		StringWriter stringWriter = new StringWriter();
		Transformer transformer = TransformerFactory.newInstance()
		// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		transformer.transform(new DOMSource(node), new StreamResult(
				stringWriter));
		return stringWriter.toString();
	}
New to GrepCode? Check out our FAQ X