<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.mulesource.org/schema/mule/http/2.0"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:spring="http://www.springframework.org/schema/beans"
            xmlns:mule="http://www.mulesource.org/schema/mule/core/2.0"
            xmlns:tcp="http://www.mulesource.org/schema/mule/tcp/2.0"
            targetNamespace="http://www.mulesource.org/schema/mule/http/2.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified">

    <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
    <xsd:import namespace="http://www.springframework.org/schema/beans"
                schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"/>
    <xsd:import namespace="http://www.mulesource.org/schema/mule/core/2.0" 
                schemaLocation="http://www.mulesource.org/schema/mule/core/2.0/mule.xsd" />
    <xsd:import namespace="http://www.mulesource.org/schema/mule/tcp/2.0"
                schemaLocation="http://www.mulesource.org/schema/mule/tcp/2.0/mule-tcp.xsd"/>

    <xsd:element name="connector" type="httpConnectorType" substitutionGroup="mule:abstract-connector">
        <xsd:annotation>
            <xsd:documentation>
                HTTP connector.
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>

    <!-- NOTE - it's not very easy to work out what parameters inherited from TCP are actually
         used.  But it appears that the client parameters are used to set the HttpConnectionManager
         while the server parameters are used directly (the server socket appears to come from
         the underlying TcpConnector). -->

    <xsd:complexType name="httpConnectorType">
        <xsd:complexContent>
            <xsd:extension base="tcp:noProtocolTcpConnectorType">
                <xsd:attribute name="cookieSpec">
                    <xsd:annotation>
                        <xsd:documentation>
                            The type of cookie used.  Either "netscape" or "rfc2109".
                        </xsd:documentation>
                    </xsd:annotation>
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:NMTOKEN">
                            <xsd:enumeration value="netscape"/>
                            <xsd:enumeration value="rfc2109"/>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:attribute>
                <xsd:attribute name="proxyHostname" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            The proxy host name or address
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="proxyPassword" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            The password to use for proxy access.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="proxyPort" type="mule:substitutablePortNumber">
                    <xsd:annotation>
                        <xsd:documentation>
                            The proxy port number.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="proxyUsername" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            The username to use for proxy access.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="enableCookies" type="mule:substitutableBoolean">
                    <xsd:annotation>
                        <xsd:documentation>
                            Whether or not to support cookies.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="rest-service-component" type="restServiceWrapperType" substitutionGroup="mule:abstract-component">
        <xsd:annotation>
            <xsd:documentation>
                Built-in RestServiceWrapper can used to proxy REST style services as local Mule Components.
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>
    <xsd:complexType name="restServiceWrapperType">
        <xsd:complexContent>
            <xsd:extension base="mule:defaultComponentType">
                <xsd:sequence>
                    <xsd:element ref="mule:abstract-filter" minOccurs="0" maxOccurs="1"/>
                    <xsd:element name="payloadParameterName" type="mule:valueType" minOccurs="0" maxOccurs="unbounded"/>
                    <xsd:element name="requiredParameter" type="mule:keyValueType" minOccurs="0" maxOccurs="unbounded"/>
                    <xsd:element name="optionalParameter" type="mule:keyValueType" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
                <xsd:attribute name="httpMethod" default="GET" use="optional">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:NMTOKEN">
                            <xsd:enumeration value="GET"/>
                            <xsd:enumeration value="POST"/>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:attribute>
                <xsd:attribute name="serviceUrl" use="required"/>
                <xsd:attribute name="urlFromMessage" default="false" use="optional" type="xsd:boolean"/>
                <xsd:attribute name="errorExpression" use="optional" type="xsd:string"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="http-client-response-to-object-transformer" type="mule:abstractTransformerType" substitutionGroup="mule:abstract-transformer"/>
    <xsd:element name="http-response-to-string-transformer" type="mule:abstractTransformerType" substitutionGroup="mule:abstract-transformer"/>
    <xsd:element name="object-to-http-client-request-transformer" type="mule:abstractTransformerType" substitutionGroup="mule:abstract-transformer"/>
    <xsd:element name="message-to-http-response-transformer" type="mule:abstractTransformerType" substitutionGroup="mule:abstract-transformer"/>

    <xsd:element name="inbound-endpoint" type="inboundEndpointType" substitutionGroup="mule:abstract-inbound-endpoint"/>
    <xsd:complexType name="inboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:inboundEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
                <xsd:attributeGroup ref="propertyAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="outbound-endpoint" type="outboundEndpointType" substitutionGroup="mule:abstract-outbound-endpoint"/>
    <xsd:complexType name="outboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:outboundEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
                <xsd:attributeGroup ref="propertyAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="endpoint" type="globalEndpointType" substitutionGroup="mule:abstract-global-endpoint"/>
    <xsd:complexType name="globalEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:globalEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
                <xsd:attributeGroup ref="propertyAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:attributeGroup name="addressAttributes">
        <xsd:attribute name="user" type="xsd:string"/>
        <xsd:attribute name="password" type="xsd:string"/>
        <xsd:attribute name="host" type="xsd:string"/>
        <xsd:attribute name="port" type="mule:substitutablePortNumber"/>
        <xsd:attribute name="path" type="xsd:string"/>
    </xsd:attributeGroup>

    <xsd:attributeGroup name="propertyAttributes">
        <!-- maybe we mant a more general mechanism, perhaps an element for header values? -->
        <xsd:attribute name="contentType" type="xsd:string"/>
        <xsd:attribute name="method">
            <xsd:simpleType>
                <xsd:restriction base="xsd:NMTOKEN">
                    <xsd:enumeration value="OPTIONS"/>
                    <xsd:enumeration value="GET"/>
                    <xsd:enumeration value="HEAD"/>
                    <xsd:enumeration value="POST"/>
                    <xsd:enumeration value="PUT"/>
                    <xsd:enumeration value="TRACE"/>
                    <xsd:enumeration value="CONNECT"/>
                    <xsd:enumeration value="DELETE"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:attributeGroup>

</xsd:schema>
