<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
    contributors by the @authors tag. See the copyright.txt in the
    distribution for a full listing of individual 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.
-->
<switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:camel="urn:switchyard-component-camel:config:1.0" xmlns:file="urn:switchyard-component-camel-file:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:soap="urn:switchyard-component-soap:config:1.0" xmlns:http="urn:switchyard-component-http:config:1.0" xmlns:xform="urn:switchyard-config:transform:1.0" name="switchyard-quickstart-soap-addressing" targetNamespace="urn:switchyard-quickstart:soap-addressing:1.0">
  <sca:composite name="switchyard-quickstart-soap-addressing" targetNamespace="urn:switchyard-quickstart:soap-addressing:1.0">
    <sca:service name="OrderService" promote="Route/OrderService">
      <sca:interface.wsdl interface="OrderService.wsdl#wsdl.porttype(OrderService)"/>
      <soap:binding.soap>
        <soap:contextMapper includeNamespaces="http://www.w3.org/2005/08/addressing" includes=".*" soapHeadersType="DOM"/>
        <soap:wsdl>OrderService.wsdl</soap:wsdl>
        <soap:socketAddr>:${soapPort}</soap:socketAddr>
        <soap:contextPath>soap-addressing/order</soap:contextPath>
      </soap:binding.soap>
    </sca:service>
    <sca:reference name="WarehouseServiceExternal" multiplicity="0..1" promote="Route/WarehouseServiceExternal">
      <sca:interface.wsdl interface="WarehouseService.wsdl#wsdl.porttype(WarehouseService)"/>
      <soap:binding.soap>
        <soap:wsdl>WarehouseService.wsdl</soap:wsdl>
        <soap:endpointAddress>http://localhost:${soapClientPort}/soap-addressing/warehouse/WarehouseService</soap:endpointAddress>
      </soap:binding.soap>
    </sca:reference>
    <sca:component name="Route">
      <camel:implementation.camel>
        <camel:xml path="route.xml"/>
      </camel:implementation.camel>
      <sca:service name="OrderService">
        <interface.esb inputType="java:org.switchyard.quickstarts.soap.addressing.Order" outputType="java:org.switchyard.quickstarts.soap.addressing.OrderResponse"/>
      </sca:service>
      <sca:reference name="WarehouseServiceExternal">
        <interface.esb inputType="java:org.switchyard.quickstarts.soap.addressing.Order"/>
      </sca:reference>
    </sca:component>
    <sca:service name="WarehouseService" promote="Route2/WarehouseService">
      <sca:interface.wsdl interface="WarehouseService.wsdl#wsdl.porttype(WarehouseService)"/>
      <soap:binding.soap>
        <soap:contextMapper includeNamespaces="http://www.w3.org/2005/08/addressing" includes=".*" soapHeadersType="DOM"/>
        <soap:wsdl>WarehouseService.wsdl</soap:wsdl>
        <soap:socketAddr>:${soapPort}</soap:socketAddr>
        <soap:contextPath>soap-addressing/warehouse</soap:contextPath>
      </soap:binding.soap>
    </sca:service>
    <sca:component name="Route2">
      <camel:implementation.camel>
        <camel:xml path="route2.xml"/>
      </camel:implementation.camel>
      <sca:service name="WarehouseService">
        <interface.esb faultType="java:org.switchyard.quickstarts.soap.addressing.ItemNotAvailable" inputType="java:org.switchyard.quickstarts.soap.addressing.Order" outputType="java:org.switchyard.quickstarts.soap.addressing.OrderResponse"/>
        <!--<sca:interface.java interface="org.switchyard.quickstarts.soap.addressing.WarehouseService"/>-->
      </sca:service>
    </sca:component>
    <sca:service name="ClientService" promote="Route3/ClientService">
      <sca:interface.wsdl interface="ResponseService.wsdl#wsdl.porttype(ResponseService)"/>
      <soap:binding.soap>
        <soap:contextMapper includeNamespaces="http://www.w3.org/2005/08/addressing" includes=".*" soapHeadersType="DOM"/>
        <soap:wsdl>ResponseService.wsdl</soap:wsdl>
        <soap:socketAddr>:${soapPort}</soap:socketAddr>
        <soap:contextPath>soap-addressing/client</soap:contextPath>
      </soap:binding.soap>
    </sca:service>
    <sca:reference name="ClientFileService" multiplicity="1..1" promote="Route3/ClientFileService">
      <interface.esb inputType="java:java.lang.String"/>
      <file:binding.file>
        <file:directory>/tmp</file:directory>
        <file:fileName>test.txt</file:fileName>
        <file:produce>
          <file:fileExist>Override</file:fileExist>
        </file:produce>
      </file:binding.file>
    </sca:reference>
    <sca:component name="Route3">
      <camel:implementation.camel>
        <camel:xml path="client-route.xml"/>
      </camel:implementation.camel>
      <sca:service name="ClientService">
        <interface.esb inputType="java:org.switchyard.quickstarts.soap.addressing.OrderResponse"/>
      </sca:service>
      <sca:reference name="ClientFileService">
        <interface.esb inputType="java:java.lang.String"/>
      </sca:reference>
    </sca:component>
    <sca:service name="FaultService" promote="Route4/FaultService">
      <interface.esb inputType="java:java.lang.String"/>
      <http:binding.http>
         <http:contextPath>soap-addressing/fault/FaultService</http:contextPath>
      </http:binding.http>
    </sca:service>
    <sca:reference name="FaultFileService" multiplicity="1..1" promote="Route4/FaultFileService">
      <interface.esb inputType="java:java.lang.String"/>
      <file:binding.file>
        <file:directory>/tmp</file:directory>
        <file:fileName>test.txt</file:fileName>
        <file:produce>
          <file:fileExist>Override</file:fileExist>
        </file:produce>
      </file:binding.file>
    </sca:reference>
    <sca:component name="Route4">
      <camel:implementation.camel>
        <camel:xml path="fault-route.xml"/>
      </camel:implementation.camel>
      <sca:service name="FaultService">
        <interface.esb inputType="java:java.lang.String"/>
      </sca:service>
      <sca:reference name="FaultFileService">
        <interface.esb inputType="java:java.lang.String"/>
      </sca:reference>
    </sca:component>
  </sca:composite>
  <transforms>
    <xform:transform.java from="{urn:switchyard-quickstart:soap-addressing:1.0}order" to="java:org.switchyard.quickstarts.soap.addressing.Order" bean="Transformers"/>
    <xform:transform.java from="{urn:switchyard-quickstart:soap-addressing:1.0}orderResponse" to="java:org.switchyard.quickstarts.soap.addressing.OrderResponse" bean="Transformers"/>
    <xform:transform.java from="{urn:switchyard-quickstart:soap-addressing:1.0}ItemNotAvailable" to="java:org.switchyard.quickstarts.soap.addressing.ItemNotAvailable" bean="Transformers"/>
  </transforms>
  <domain>
    <properties>
      <property name="soapPort" value="${org.switchyard.component.soap.standalone.port:8080}"/>
      <property name="soapClientPort" value="${org.switchyard.component.soap.client.port:8080}"/>
      <property name="httpPort" value="${org.switchyard.component.http.standalone.port:8080}"/>
      <property name="org.switchyard.handlers.messageTrace.enabled" value="true"/>
    </properties>
  </domain>
</switchyard>
