<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="WorkflowCallbackService" transports="https http"
       startOnLoad="true">
    <description/>
    <target>
        <inSequence>
            <property name="messageType" value="application/json" scope="axis2"/>
            <property xmlns:p="http://callback.workflow.apimgt.carbon.wso2.org"
                      xmlns:ns="http://callback.workflow.apimgt.carbon.wso2.org" name="uri.var.workflowRef"
                      expression="$body//p:resumeEvent/ns:workflowReference"/>
            <property xmlns:p="http://callback.workflow.apimgt.carbon.wso2.org"
                      xmlns:ns="http://callback.workflow.apimgt.carbon.wso2.org" name="status"
                      expression="$body//p:resumeEvent/ns:status"/>
            <property xmlns:p="http://callback.workflow.apimgt.carbon.wso2.org"
                      xmlns:ns="http://callback.workflow.apimgt.carbon.wso2.org" name="description"
                      expression="$body//p:resumeEvent/ns:description"/>
            <payloadFactory media-type="json">
                <format>
                    {
                    "status":"$1",
                    "description":"$2"
                    }
                </format>
                <args>
                    <arg evaluator="xml" expression="$ctx:status"/>
                    <arg evaluator="xml" expression="$ctx:description"/>
                </args>
            </payloadFactory>
            <send>
                <endpoint>
                    <http method="POST"
                          uri-template="https://localhost:9443/api/am/admin/v0.16/workflows/update-workflow-status?workflowReferenceId={uri.var.workflowRef}"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
            <filter xpath="//jsonObject">
                <then>
                    <enrich>
                        <source clone="true" xpath="//jsonObject/*"/>
                        <target type="property" property="BPS_PAYLOAD"/>
                    </enrich>
                    <enrich>
                        <source type="property" clone="true" property="BPS_PAYLOAD"/>
                        <target type="body"/>
                    </enrich>
                </then>
                <else/>
            </filter>
            <log level="full"/>
            <send/>
        </outSequence>
    </target>
    <publishWSDL>
        <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                          xmlns:ns="http://callback.workflow.apimgt.carbon.wso2.org"
                          xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
                          xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
                          xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
                          xmlns:xs="http://www.w3.org/2001/XMLSchema"
                          xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
                          xmlns:ns1="http://org.apache.axis2/xsd"
                          xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                          targetNamespace="http://callback.workflow.apimgt.carbon.wso2.org">
            <wsdl:documentation>WorkflowCallbackService</wsdl:documentation>
            <wsdl:types>
                <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
                           targetNamespace="http://callback.workflow.apimgt.carbon.wso2.org">
                    <xs:element name="resumeEvent">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element minOccurs="0" name="workflowReference" nillable="true" type="xs:string"/>
                                <xs:element minOccurs="0" name="status" nillable="true" type="xs:string"/>
                                <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="resumeEventResponse">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:schema>
            </wsdl:types>
            <wsdl:message name="resumeEventRequest">
                <wsdl:part name="parameters" element="ns:resumeEvent"/>
            </wsdl:message>
            <wsdl:message name="resumeEventResponse">
                <wsdl:part name="parameters" element="ns:resumeEventResponse"/>
            </wsdl:message>
            <wsdl:portType name="WorkflowCallbackServicePortType">
                <wsdl:operation name="resumeEvent">
                    <wsdl:input message="ns:resumeEventRequest" wsaw:Action="urn:resumeEvent"/>
                    <wsdl:output message="ns:resumeEventResponse" wsaw:Action="urn:resumeEventResponse"/>
                </wsdl:operation>
            </wsdl:portType>
            <wsdl:binding name="WorkflowCallbackServiceSoap11Binding" type="ns:WorkflowCallbackServicePortType">
                <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
                <wsdl:operation name="resumeEvent">
                    <soap:operation soapAction="urn:resumeEvent" style="document"/>
                    <wsdl:input>
                        <soap:body use="literal"/>
                    </wsdl:input>
                    <wsdl:output>
                        <soap:body use="literal"/>
                    </wsdl:output>
                </wsdl:operation>
            </wsdl:binding>
            <wsdl:binding name="WorkflowCallbackServiceSoap12Binding" type="ns:WorkflowCallbackServicePortType">
                <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
                <wsdl:operation name="resumeEvent">
                    <soap12:operation soapAction="urn:resumeEvent" style="document"/>
                    <wsdl:input>
                        <soap12:body use="literal"/>
                    </wsdl:input>
                    <wsdl:output>
                        <soap12:body use="literal"/>
                    </wsdl:output>
                </wsdl:operation>
            </wsdl:binding>
            <wsdl:binding name="WorkflowCallbackServiceHttpBinding" type="ns:WorkflowCallbackServicePortType">
                <http:binding verb="POST"/>
                <wsdl:operation name="resumeEvent">
                    <http:operation location="resumeEvent"/>
                    <wsdl:input>
                        <mime:content type="text/xml" part="parameters"/>
                    </wsdl:input>
                    <wsdl:output>
                        <mime:content type="text/xml" part="parameters"/>
                    </wsdl:output>
                </wsdl:operation>
            </wsdl:binding>
            <wsdl:service name="WorkflowCallbackService">
                <wsdl:port name="WorkflowCallbackServiceHttpsSoap11Endpoint"
                           binding="ns:WorkflowCallbackServiceSoap11Binding">
                    <soap:address
                            location="https://localhost:8243/services/WorkflowCallbackService.WorkflowCallbackServiceHttpsSoap11Endpoint/"/>
                </wsdl:port>
                <wsdl:port name="WorkflowCallbackServiceHttpSoap11Endpoint"
                           binding="ns:WorkflowCallbackServiceSoap11Binding">
                    <soap:address
                            location="http://localhost:8280/services/WorkflowCallbackService.WorkflowCallbackServiceHttpSoap11Endpoint/"/>
                </wsdl:port>
                <wsdl:port name="WorkflowCallbackServiceHttpsSoap12Endpoint"
                           binding="ns:WorkflowCallbackServiceSoap12Binding">
                    <soap12:address
                            location="https://localhost:8243/services/WorkflowCallbackService.WorkflowCallbackServiceHttpsSoap12Endpoint/"/>
                </wsdl:port>
                <wsdl:port name="WorkflowCallbackServiceHttpSoap12Endpoint"
                           binding="ns:WorkflowCallbackServiceSoap12Binding">
                    <soap12:address
                            location="http://localhost:8280/services/WorkflowCallbackService.WorkflowCallbackServiceHttpSoap12Endpoint/"/>
                </wsdl:port>
                <wsdl:port name="WorkflowCallbackServiceHttpsEndpoint" binding="ns:WorkflowCallbackServiceHttpBinding">
                    <http:address
                            location="https://localhost:8243/services/WorkflowCallbackService.WorkflowCallbackServiceHttpsEndpoint/"/>
                </wsdl:port>
                <wsdl:port name="WorkflowCallbackServiceHttpEndpoint" binding="ns:WorkflowCallbackServiceHttpBinding">
                    <http:address
                            location="http://localhost:8280/services/WorkflowCallbackService.WorkflowCallbackServiceHttpEndpoint/"/>
                </wsdl:port>
            </wsdl:service>
        </wsdl:definitions>
    </publishWSDL>
</proxy>
