0
votes

I'm using WSO2 EI 6.3v.I want to pass application/x-www-form-urlencoded data to the rezlive hotel Supplier. In hear i put my code and response.

CODE

<inSequence>
        <log category="WARN" level="full">
            <property name="API BEGIN" value="Test_Supplier API"/>
        </log>
        <payloadFactory media-type="xml">
            <format>
                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                    <soapenv:Body>
                        <HotelFindRequest xmlns="">
                            $1
                        </HotelFindRequest>
                    </soapenv:Body>
                </soapenv:Envelope>
            </format>
            <args>
                <arg evaluator="xml" expression="$env/*[local-name()='Body']/*[local-name()='HotelFindRequest']/*"/>
            </args>
        </payloadFactory>
        <property expression="$env/*[local-name()='Body']/*" name="xmlbody" scope="default" type="STRING"/>
        <log>
            <property expression="$ctx:xmlbody" name="Body======="/>
        </log>
        <property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
        <property expression="$body" name="payload" scope="default" type="STRING"/>
        <property name="uri.var.url" scope="default" type="STRING" value="http://test.xmlhub.com/testpanel.php/action/findhotel"/>
        <call>
            <endpoint>
                <address format="pox" uri="http://test.xmlhub.com/testpanel.php/action/findhotel?XML={xmlbody}"/>
            </endpoint>
        </call>
        <respond/>
</inSequence>

Body Log

<HotelFindRequest>
<Authentication>
    <AgentCode>xxxxxxx</AgentCode>
    <UserName>xxxxx</UserName>
    <Password>xxxxxx</Password>
</Authentication>
<Booking>
    <ArrivalDate>22/05/2019</ArrivalDate>
    <DepartureDate>25/05/2019</DepartureDate>
    <CountryCode>AE</CountryCode>
    <City>968</City>
    <GuestNationality>LK</GuestNationality>
    <HotelRatings>
        <HotelRating>1</HotelRating><HotelRating>2</HotelRating>
        <HotelRating>3</HotelRating><HotelRating>4</HotelRating>
        <HotelRating>5</HotelRating>
    </HotelRatings>
    <Rooms>
        <Room>
            <Type>Room-1</Type>
            <NoOfAdults>2</NoOfAdults>
            <NoOfChilds>0</NoOfChilds>
        </Room>
        <Room>
            <Type>Room-2</Type>
            <NoOfAdults>1</NoOfAdults>
            <NoOfChilds>0</NoOfChilds>
        </Room>
        <Room>
            <Type>Room-3</Type>
            <NoOfAdults>2</NoOfAdults>
            <NoOfChilds>0</NoOfChilds>
        </Room>
        <Room>
            <Type>Room-4</Type>
            <NoOfAdults>3</NoOfAdults>
            <NoOfChilds>0</NoOfChilds>
        </Room>
    </Rooms>
</Booking>

Response comming as

<HotelFindResponse>
<error>Please provide agentcode.</error>
<error>Please provide username.</error>
<error>Please provide password.</error></HotelFindResponse>

But I pass same configuration in POSTMAN, give me the correct response.

enter image description here

I put the same configuration in Postman. I tried so meny ways to get response.All are failed. What is wrong with that code?. Please help.

3

3 Answers

1
votes

Can you try with HTTP endpoint (https://docs.wso2.com/display/EI640/HTTP+Endpoint) using post?

Payload factory already sets the body, so it should work right away as it will try to post it.

0
votes

Try using "uri.var.xmlBody" property name instead of simple "xmlBody":

<property expression="$env/*[local-name()='Body']/*" name="uri.var.xmlBody" scope="default" type="STRING"/>

<call>
        <endpoint>
            <address format="pox" uri="http://test.xmlhub.com/testpanel.php/action/findhotel?XML={uri.var.xmlBody}"/>
        </endpoint>
</call>
0
votes

Can you try this? from here

<payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Body>
                     <root xmlns="">
                        <XML>$1</XML>
                     </root>
                  </soapenv:Body>
               </soapenv:Envelope>
            </format>
            <args>
               <arg evaluator="xml" expression="$ctx:xmlbody"></arg>              
            </args>
         </payloadFactory>             
         <property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"></property>
         <property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"></property>
         <call>
<http method="post" uri-template="test.xmlhub.com/testpanel.php/action/findhotel"/>
</call>