<?xml version="1.0" encoding="UTF-8"?>
<!--
 - Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors.
 - 
 - 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.
 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="urn:switchyard-component-soap:config:1.0"
        xmlns:soap="urn:switchyard-component-soap:config:1.0"
        xmlns:swyd="urn:switchyard-config:switchyard:1.0"
        xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
        elementFormDefault="qualified">

    <import namespace="urn:switchyard-config:switchyard:1.0"/>
    <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"/>

    <complexType name="ContextMapperType">
        <complexContent>
            <extension base="swyd:ContextMapperType">
                <attribute name="soapHeadersType" type="soap:soapHeadersType" use="optional" default="VALUE"/>
            </extension>
        </complexContent>
    </complexType>
    
    <complexType name="MessageComposerType">
        <complexContent>
            <extension base="swyd:MessageComposerType">
                <attribute name="unwrapped" type="boolean" use="optional" />
            </extension>
        </complexContent>
    </complexType>
    
    <element name="binding.soap" type="soap:SOAPBindingType" substitutionGroup="swyd:binding.switchyard"/>
    <complexType name="SOAPBindingType">
        <complexContent>
            <extension base="swyd:SwitchYardBindingType">
                <sequence>
                    <element name="contextMapper" type="soap:ContextMapperType" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Specify the ContextMapper to be used.</documentation>
                        </annotation>
                    </element>
                    <element name="messageComposer" type="soap:MessageComposerType" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Specify the MessageComposer to be used.</documentation>
                        </annotation>
                    </element>
                    <element name="wsdl" type="string" minOccurs="1" maxOccurs="1">
                        <annotation>
                            <documentation>A WSDL file name that can be found in classpath else can be a file://, http:// or https:// URL location.</documentation>
                        </annotation>
                    </element>
                    <element name="wsdlPort" type="soap:wsdlPortType" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Specify the WSDL port to be used. The string can be in the form {namespaceURI}serviceName:portName", with the "{namespaceURI}" and "serviceName:" part being optional.</documentation>
                        </annotation>
                    </element>
                    <choice>
                        <sequence>
                            <element name="socketAddr" type="string" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>Specify the IP Socket Address to be used. The string can be in the form "hostName/ipAddress:portNumber", with the "hostName/ipAddress:" or ":portNumber" part being optional. Applicable only for service bindings.</documentation>
                                </annotation>
                            </element>
                            <element name="contextPath" type="string" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>The context path used in the HTTP URL where the endpoint will be hosted. Applicable only for service bindings.</documentation>
                                </annotation>
                            </element>
                            <element name="endpointConfig" type="soap:EndpointConfigType" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>The JBossWS @EndpointConfig to add</documentation>
                                </annotation>
                            </element>
                        </sequence>
                        <sequence>
                            <element name="endpointAddress" type="string" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>The endpoint address override. Applicable only for reference bindings.</documentation>
                                </annotation>
                            </element>
                            <choice>
                                <element name="basic" type="soap:BasicAuthenticationType" minOccurs="0" maxOccurs="1"/>
                                <element name="ntlm" type="soap:NTLMAuthenticationType" minOccurs="0" maxOccurs="1"/>
                            </choice>
                            <element name="proxy" type="soap:ProxyType" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>Http proxy settings.</documentation>
                                </annotation>
                            </element>
                        </sequence>
                    </choice>
                    <element name="mtom" type="soap:MtomType" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Mtom feature override. By default this feature is enabled. Use this to disable or change threshold value.</documentation>
                        </annotation>
                    </element>
                    <element name="inInterceptors" type="soap:InterceptorsType" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>The Apache CXF @InInterceptors to add</documentation>
                        </annotation>
                    </element>
                    <element name="outInterceptors" type="soap:InterceptorsType" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>The Apache CXF @OutInterceptors to add</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="BasicAuthenticationType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element name="user" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>User name.</documentation>
                        </annotation>
                    </element>
                    <element name="password" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>Password.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="NTLMAuthenticationType">
        <complexContent>
            <extension base="soap:BasicAuthenticationType">
                <sequence>
                    <element name="domain" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>The NTLM Domain.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="ProxyType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element name="type" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy Type. Default is HTTP. Allowed values are HTTP and SOCKS</documentation>
                        </annotation>
                    </element>
                    <element name="host" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy Host.</documentation>
                        </annotation>
                    </element>
                    <element name="port" type="integer" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy Port.</documentation>
                        </annotation>
                    </element>
                    <element name="user" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy user name.</documentation>
                        </annotation>
                    </element>
                    <element name="password" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy password.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="MtomType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <attribute name="enabled" type="boolean" use="optional"/>
                <attribute name="threshold" type="integer" use="optional"/>
                <attribute name="xopExpand" type="boolean" use="optional"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="EndpointConfigType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <attribute name="configFile" type="string" use="optional"/>
                <attribute name="configName" type="string" use="optional"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="InterceptorsType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element ref="soap:interceptor" minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <element name="interceptor" type="soap:InterceptorType"/>
    <complexType name="InterceptorType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element ref="soap:properties" minOccurs="0" maxOccurs="1"/>
                </sequence>
                <attribute name="class" type="string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <element name="properties" type="soap:PropertiesType"/>
    <complexType name="PropertiesType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element ref="soap:property" minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <element name="property" type="soap:PropertyType"/>
    <complexType name="PropertyType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <attribute name="name" type="string" use="required"/>
                <attribute name="value" type="string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <simpleType name="soapHeadersType">
        <restriction base="string">
            <enumeration value="CONFIG"/>
            <enumeration value="DOM"/>
            <enumeration value="VALUE"/>
            <enumeration value="XML"/>
        </restriction>
    </simpleType>

    <simpleType name="wsdlPortType">
        <restriction base="string">
            <pattern value="\{.+\}.+:[^:]+|.+:[^:]+|[^:]+"></pattern>
        </restriction>
    </simpleType>

</schema>
