0
votes

I am new working with wso2 api manager, and I need to pause a SOAP service and take it to a REST API, I have seen all the documentation, but none responds to my problem, I already created an input sequence

getProdRequestInSequence.xml

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="getProdRequestInSequence" ><!-- This is the SOAP action which the backend SOAP operation expects, we set it in a header mediator --><header description="SOAPAction" name="SOAPAction" scope="transport" value="http://localhost:81/soap/products.php/query/getProd"/><!-- We are storing the input values which the end users input for these values into these two properties --><property name="uri.var.categoria" expression="$url:categoria"/>
<!-- Since we do not want the URL pattern we mentioned to be sent to the backend we need to add the below property to remove it --><property name="REST_URL_POSTFIX" scope="axis2" action="remove"/><!-- Now we need to create the actual payload which the backend requires. For that we use the payload factory mediator --><payloadFactory description="transform" media-type="xml">
  <format>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://localhost:81/soap/products.php/query/">
  <soapenv:Header/>
  <soapenv:Body>
  <quer:getProd>
    <quer:categoria>$1</quer:categoria>
  </quer:getProd></soapenv:Body>
  </soapenv:Envelope>
  </format>
  <args>
    <arg expression="get-property(‘uri.var.categoria’)"/>
  </args>
</payloadFactory><!-- Here we are setting the content type which the web service expects --><property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="application/soap+xml"/>
</sequence>

xml_to_json_out_message.xml

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="xml_to_json_out_message" >
<!-- Transforms the response to a JSON -->
    <property description="message" name="messageType" scope="axis2" type="STRING" value="application/json"/>
</sequence>

Now, according to the documentation, these files once created, I charge in the Message Mediation Policies, and should work perfectly but it gives me this error

Gateway Failures

Failed to Publish Environments Production and Sandbox Error in deploying the sequence to gateway###

Thanks in advance for the help

getProdRequestInSequence.xml

 <?xml version="1.0" encoding="UTF-8"?>
    <sequence xmlns="http://ws.apache.org/ns/synapse" name="getProdRequestInSequence" ><!-- This is the SOAP action which the backend SOAP operation expects, we set it in a header mediator --><header description="SOAPAction" name="SOAPAction" scope="transport" value="http://localhost:81/soap/products.php/query/getProd"/><!-- We are storing the input values which the end users input for these values into these two properties --><property name="uri.var.categoria" expression="$url:categoria"/>
    <!-- Since we do not want the URL pattern we mentioned to be sent to the backend we need to add the below property to remove it --><property name="REST_URL_POSTFIX" scope="axis2" action="remove"/><!-- Now we need to create the actual payload which the backend requires. For that we use the payload factory mediator --><payloadFactory description="transform" media-type="xml">
      <format>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://localhost:81/soap/products.php/query/">
      <soapenv:Header/>
      <soapenv:Body>
      <quer:getProd>
        <quer:categoria>$1</quer:categoria>
      </quer:getProd></soapenv:Body>
      </soapenv:Envelope>
      </format>
      <args>
        <arg expression="get-property(‘uri.var.categoria’)"/>
      </args>
    </payloadFactory><!-- Here we are setting the content type which the web service expects --><property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="application/soap+xml"/>
    </sequence>

and the output sequence

xml_to_json_out_message.xml

 <?xml version="1.0" encoding="UTF-8"?>
    <sequence xmlns="http://ws.apache.org/ns/synapse" name="xml_to_json_out_message" >
    <!-- Transforms the response to a JSON -->
        <property description="message" name="messageType" scope="axis2" type="STRING" value="application/json"/>
    </sequence>

Now, according to the documentation, these files once created, I charge in the Message Mediation Policies, and should work perfectly but it gives me this error

Gateway Failures

Failed to Publish Environments Production and Sandbox Error in deploying the sequence to gateway

Thanks in advance for the help

2
The version of WSO2 API MANAGER is 2.6.0*Livan Gonzalez
This error normally occurs when there is an validation error is your sequence. Can you try validating your in-sequence in any online XML validator and check whether it is valid?Vithursa M

2 Answers

0
votes

There is a syntax mismatch in the provided getProdRequestInSequence.xml synapse configuration file.

The uri.var.categoria has been enclosed with a special character (‘) inside the get-property() method and which is not a single-quote symbol ('). Please find the updated synapse configuration file below

getProdRequestInSequence.xml

<?xml version="1.0" encoding="UTF-8"?>
    <sequence xmlns="http://ws.apache.org/ns/synapse" name="getProdRequestInSequence" >
    <!-- This is the SOAP action which the backend SOAP operation expects, we set it in a header mediator -->
    <header description="SOAPAction" name="SOAPAction" scope="transport" value="http://localhost:81/soap/products.php/query/getProd"/>
    <!-- We are storing the input values which the end users input for these values into these two properties -->
    <property name="uri.var.categoria" expression="$url:categoria"/>
    <!-- Since we do not want the URL pattern we mentioned to be sent to the backend we need to add the below property to remove it -->
    <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
    <!-- Now we need to create the actual payload which the backend requires. For that we use the payload factory mediator -->
    <payloadFactory description="transform" media-type="xml">
        <format>
            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://localhost:81/soap/products.php/query/">
                <soapenv:Header/>
                <soapenv:Body>
                    <quer:getProd>
                        <quer:categoria>$1</quer:categoria>
                    </quer:getProd>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg expression="get-property('uri.var.categoria')"/>
        </args>
    </payloadFactory>
    <!-- Here we are setting the content type which the web service expects -->
    <property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="application/soap+xml"/>
</sequence>
0
votes

Resolution for the above-mentioned issue:

At the moment Your approach has a special character "‘" which is common if you use a mac book for the developments. Replacing the single quotes with the correct character will resolve your current issues.


Recommended Approach with WSo2 API Manager :

WSO2 API Manager has the capability of exposing a SOAP Service/API as a REST API Out of the box without any sequences or synapse level configurations.

To get the REST service exposed with WSO2 API Manager you just have to provide the backend URL and the WDSL file with this feature.

Please refer to the Documentation here.