// Path: common/src/main/java/com/nortal/jroad/enums/XRoadProtocolVersion.java
// public enum XRoadProtocolVersion {
// 
//   V2_0("2.0", "xtee", "http://x-tee.riik.ee/xsd/xtee.xsd"),
//   V3_0("3.0", "xrd", "http://x-rd.net/xsd/xroad.xsd"),
//   V3_1("3.1", "xrd", "http://x-road.ee/xsd/x-road.xsd"),
//   V4_0("4.0", "xrd", "http://x-road.eu/xsd/xroad.xsd");
// 
//   private final String code;
//   private final String namespacePrefix;
//   private final String namespaceUri;
// 
//   private XRoadProtocolVersion(String code, String namespacePrefix, String namespaceUri) {
//     this.code = code;
//     this.namespaceUri = namespaceUri;
//     this.namespacePrefix = namespacePrefix;
//   }
// 
//   public String getCode() {
//     return code;
//   }
// 
//   public String getNamespacePrefix() {
//     return namespacePrefix;
//   }
// 
//   public String getNamespaceUri() {
//     return namespaceUri;
//   }
// 
//   public static XRoadProtocolVersion getValueByVersionCode(String code) {
//     for (XRoadProtocolVersion version : XRoadProtocolVersion.values()) {
//       if (version.getCode().equals(code)) {
//         return version;
//       }
//     }
//     return null;
//   }
// 
//   public static XRoadProtocolVersion getValueByNamespaceURI(String uri) {
//     for (XRoadProtocolVersion version : XRoadProtocolVersion.values()) {
//       if (version.getNamespaceUri().startsWith(uri)) {
//         return version;
//       }
//     }
//     return null;
//   }
// 
// }
// 
// Path: common/src/main/java/com/nortal/jroad/model/BeanXTeeMessage.java
// @Deprecated
// public class BeanXTeeMessage<T> implements XTeeMessage<T> {
//   private List<XTeeAttachment> attachments;
//   private XTeeHeader header;
//   private T content;
// 
//   public BeanXTeeMessage(XTeeHeader header, T content, List<XTeeAttachment> attachments) {
//     this.attachments = attachments;
//     this.header = header;
//     this.content = content;
//   }
// 
//   public List<XTeeAttachment> getAttachments() {
//     return attachments;
//   }
// 
//   public XTeeHeader getHeader() {
//     return header;
//   }
// 
//   public T getContent() {
//     return content;
//   }
// 
//   public void setContent(T content) {
//     this.content = content;
//   }
// 
//   public void setAttachments(List<XTeeAttachment> attachments) {
//     this.attachments = attachments;
//   }
// 
//   public void setHeader(XTeeHeader header) {
//     this.header = header;
//   }
// }


import com.nortal.jroad.enums.XRoadProtocolVersion;
import com.nortal.jroad.model.BeanXTeeMessage;
import com.nortal.jroad.model.XTeeAttachment;
import com.nortal.jroad.model.XTeeHeader;
import com.nortal.jroad.model.XTeeMessage;
import com.nortal.jroad.util.SOAPUtil;
import com.nortal.jroad.wsdl.XTeeWsdlDefinition;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.endpoint.MessageEndpoint;
import org.springframework.ws.wsdl.wsdl11.provider.SuffixBasedMessagesProvider;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
 * Copyright 2015 Nortal Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language governing permissions and limitations under the
 * License.
 **/

package com.nortal.jroad.endpoint;


/**
 * Base class for X-Tee Spring web-service endpoints, extension classes must implement
 * {@link AbstractXTeeBaseEndpoint#invokeInternal(XTeeMessage request, XTeeMessage response)}.
 * 
 * @author Roman Tekhov
 * @author Dmitri Danilkin
 * @author Lauri Lättemäe (lauri.lattemae@nortal.com) - protocol 4.0
 */
public abstract class AbstractXTeeBaseEndpoint implements MessageEndpoint {
  protected boolean metaService = false;
// Path: common/src/main/java/com/nortal/jroad/enums/XRoadProtocolVersion.java
// public enum XRoadProtocolVersion {
// 
//   V2_0("2.0", "xtee", "http://x-tee.riik.ee/xsd/xtee.xsd"),
//   V3_0("3.0", "xrd", "http://x-rd.net/xsd/xroad.xsd"),
//   V3_1("3.1", "xrd", "http://x-road.ee/xsd/x-road.xsd"),
//   V4_0("4.0", "xrd", "http://x-road.eu/xsd/xroad.xsd");
// 
//   private final String code;
//   private final String namespacePrefix;
//   private final String namespaceUri;
// 
//   private XRoadProtocolVersion(String code, String namespacePrefix, String namespaceUri) {
//     this.code = code;
//     this.namespaceUri = namespaceUri;
//     this.namespacePrefix = namespacePrefix;
//   }
// 
//   public String getCode() {
//     return code;
//   }
// 
//   public String getNamespacePrefix() {
//     return namespacePrefix;
//   }
// 
//   public String getNamespaceUri() {
//     return namespaceUri;
//   }
// 
//   public static XRoadProtocolVersion getValueByVersionCode(String code) {
//     for (XRoadProtocolVersion version : XRoadProtocolVersion.values()) {
//       if (version.getCode().equals(code)) {
//         return version;
//       }
//     }
//     return null;
//   }
// 
//   public static XRoadProtocolVersion getValueByNamespaceURI(String uri) {
//     for (XRoadProtocolVersion version : XRoadProtocolVersion.values()) {
//       if (version.getNamespaceUri().startsWith(uri)) {
//         return version;
//       }
//     }
//     return null;
//   }
// 
// }
// 
// Path: common/src/main/java/com/nortal/jroad/model/BeanXTeeMessage.java
// @Deprecated
// public class BeanXTeeMessage<T> implements XTeeMessage<T> {
//   private List<XTeeAttachment> attachments;
//   private XTeeHeader header;
//   private T content;
// 
//   public BeanXTeeMessage(XTeeHeader header, T content, List<XTeeAttachment> attachments) {
//     this.attachments = attachments;
//     this.header = header;
//     this.content = content;
//   }
// 
//   public List<XTeeAttachment> getAttachments() {
//     return attachments;
//   }
// 
//   public XTeeHeader getHeader() {
//     return header;
//   }
// 
//   public T getContent() {
//     return content;
//   }
// 
//   public void setContent(T content) {
//     this.content = content;
//   }
// 
//   public void setAttachments(List<XTeeAttachment> attachments) {
//     this.attachments = attachments;
//   }
// 
//   public void setHeader(XTeeHeader header) {
//     this.header = header;
//   }
// }


// Path: server/src/main/java/com/nortal/jroad/endpoint/AbstractXTeeBaseEndpoint.java
import com.nortal.jroad.enums.XRoadProtocolVersion;
import com.nortal.jroad.model.BeanXTeeMessage;
import com.nortal.jroad.model.XTeeAttachment;
import com.nortal.jroad.model.XTeeHeader;
import com.nortal.jroad.model.XTeeMessage;
import com.nortal.jroad.util.SOAPUtil;
import com.nortal.jroad.wsdl.XTeeWsdlDefinition;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.endpoint.MessageEndpoint;
import org.springframework.ws.wsdl.wsdl11.provider.SuffixBasedMessagesProvider;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Copyright 2015 Nortal Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language governing permissions and limitations under the
 * License.
 **/

package com.nortal.jroad.endpoint;


/**
 * Base class for X-Tee Spring web-service endpoints, extension classes must implement
 * {@link AbstractXTeeBaseEndpoint#invokeInternal(XTeeMessage request, XTeeMessage response)}.
 * 
 * @author Roman Tekhov
 * @author Dmitri Danilkin
 * @author Lauri Lättemäe (lauri.lattemae@nortal.com) - protocol 4.0
 */
public abstract class AbstractXTeeBaseEndpoint implements MessageEndpoint {
  protected boolean metaService = false;
  protected XRoadProtocolVersion version;