0
votes

I'm trying to expose SOAP backend as REST API using wso2 ESB. I'm using payload factory to send the soap body message, but it doesn't work.

This is my API resource in wso2 esb code :

<?xml version="1.0" encoding="UTF-8"?>
<api context="/akademik" name="SampleAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/students?symbol={symbol}">
    <inSequence>
        <log level="custom">
            <property expression="$url:symbol" name="symbol"/>
        </log>
        <payloadFactory media-type="xml">
            <format>
                <soapenv:Envelope xmlns:sem="http://semogabisa.te.net/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                    <soapenv:Header/>
                    <soapenv:Body>
                        <sem:sayHi>
                            <arg0>$1</arg0>
                        </sem:sayHi>
                    </soapenv:Body>
                </soapenv:Envelope>
            </format>
            <args>
                <arg evaluator="xml" expression="$url:symbol"/>
            </args>
        </payloadFactory>
        <header scope="default">
            <m:complexHeader xmlns:m="http://org.synapse.example">
                <m:property key="Content-Type" value="application/xml"/>
            </m:complexHeader>
        </header>
        <send>
            <endpoint>
                <address format="soap11" uri="http://localhost:8084/HelloWorld"/>
            </endpoint>
        </send>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
    <faultSequence/>
</resource>

Soap messages are not sent to the backend web service, it says null.

I've test the backend service with SOAPUI with same soap envelope format and it's working

enter image description here

1

1 Answers

0
votes

I think you make some mistake on the header mediator. "HelloWorld" back end service didn't need the SOAP header based on your SOAP UI request. so remove the header mediator.

Select Synapse if you want to manipulate SOAP headers. Select Transport if you want to manipulate HTTP headers.

And it's seems back end is SOAP11, SOAP11 type is "text/xml". Your may need set this property.

<property name="messageType" value="text/xml" scope="axis2"/>

When you send message out from ESB, you need set property "messageType", then ESB will formatter the message that match back end required.

You may probably need this property, if you found ESB append some context to your back end URI when send message to back end.

<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/> 

Good Tips:
Please open your "synapse.transport.http.wire" as DEBUG, this will output every message in and out from ESB. This log will including HTTP header and body. After you got the wire log, you can compare wire log with your SOAPUI request, then find out which part is wrong.
https://docs.wso2.com/display/ESB481/Setting+Up+Logging