Search code examples
wso2wso2-esbwso2-enterprise-integratorwso2-micro-integrator

receive and pass JWT response through WSO2


I have case that my application received JWT response from another external end point but I faced an issue that the wso2 can't pass and receive the JWT response and I got this error message: "Error while building Passthrough stream org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'e' (code 101) in prolog; expected '<'"

How I can solve this issue?

I checked the axis2 file for message builder and message formatter:

    <messageBuilders>
        <messageBuilder contentType="application/xml"
                        class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
        <messageBuilder contentType="application/x-www-form-urlencoded"
                        class="org.apache.synapse.commons.builders.XFormURLEncodedBuilder"/>
        <messageBuilder contentType="multipart/form-data"
                        class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
        <messageBuilder contentType="application/json"
                        class="org.wso2.micro.integrator.core.json.JsonStreamBuilder"/>
        <messageBuilder contentType="application/json/badgerfish"
                        class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
        <messageBuilder contentType="text/javascript"
                        class="org.apache.axis2.json.JSONBuilder"/>
        <messageBuilder contentType="text/plain"
                        class="org.apache.axis2.format.PlainTextBuilder"/>
        <messageBuilder contentType="application/octet-stream"
                        class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
        <messageBuilder contentType="application/binary"
                        class="org.apache.axis2.format.BinaryBuilder"/>
    </messageBuilders>


    <messageFormatters>
        <messageFormatter contentType="application/x-www-form-urlencoded"
                          class="org.apache.synapse.commons.formatters.XFormURLEncodedFormatter"/>
        <messageFormatter contentType="multipart/form-data"
                          class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
        <messageFormatter contentType="application/xml"
                          class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
        <messageFormatter contentType="text/xml"
                          class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
        <messageFormatter contentType="application/soap+xml"
                          class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
        <messageFormatter contentType="text/plain"
                          class="org.apache.axis2.format.PlainTextFormatter"/>
        <messageFormatter contentType="application/json"
                          class="org.wso2.micro.integrator.core.json.JsonStreamFormatter"/>
        <messageFormatter contentType="application/json/badgerfish"
                          class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
        <messageFormatter contentType="text/javascript"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>
        <messageFormatter contentType="application/octet-stream"
                          class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
        <messageFormatter contentType="application/binary"
                          class="org.apache.axis2.format.BinaryFormatter"/>
    </messageFormatters>

Solution

  • It seems you are using MI, if so add the following message builder to the deployment.toml, which allows you to consume the encoded JWT message as plain text.

    [[custom_message_builders]]
    class = "org.apache.axis2.format.PlainTextBuilder"
    content_type = "application/jwt"