0
votes

I try to adapt mule "Proxy a SOAP Api Example" to proxing my .NET ASMX Service, so i create a flow like this:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" version="EE-3.7.0" 
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" 
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
xmlns:http="http://www.mulesoft.org/schema/mule/http" 
xmlns:spring="http://www.springframework.org/schema/beans" 
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <http:listener-config doc:name="HTTP Listener Configuration" host="127.0.0.1" name="HTTP_Proxy_Listener_Configuration" port="8077"/>
    <http:request-config doc:name="HTTP Request Configuration" host="concert.ru" name="HTTP_Request_Configuration" port="80"/>
    <flow name="main">
        <http:listener config-ref="HTTP_Proxy_Listener_Configuration" doc:name="Receive HTTP Requests From Apps" path="/"/>
        <cxf:proxy-service doc:name="Check WSDL"  namespace="http://concert.ru/InteropWS/" payload="envelope" port="MobileSoap" service="Mobile" wsdlLocation="http://concert.ru/InteropWS/v2/Mobile.asmx?WSDL" enableMuleSoapHeaders="false"/>
        <flow-ref doc:name="Copy HTTP Headers" name="copy-headers"/>
        <cxf:proxy-client doc:name="Proxy Client" enableMuleSoapHeaders="false" payload="envelope"/>
        <flow-ref name="restore-soapaction" doc:name="restore-soapaction" doc:description="it's important! soap client proxy clear soapaction header"/>
        <http:request config-ref="HTTP_Request_Configuration" doc:name="Send Requests to API" method="POST" path="InteropWS/v2/Mobile.asmx"/>
        <flow-ref doc:name="Copy HTTP Headers" name="copy-headers"/>
        <logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
        <catch-exception-strategy doc:name="Catch Exception Strategy">
            <logger message="new String(#[payload])" level="INFO" doc:name="Logger"/>
        </catch-exception-strategy>
    </flow>
    <sub-flow name="copy-headers">
        <copy-properties doc:name="Copy HTTP headers" propertyName="*"/>
        <remove-property doc:name="Remove host property" propertyName="Host"/>
        <remove-property doc:name="Remove Content Length Header" propertyName="Content-Length"/>
        <remove-property doc:name="Remove HTTP synthetic properties" propertyName="http.*"/>
        <remove-property doc:name="Remove MULE properties" propertyName="MULE_*"/>
        <remove-property doc:name="Remove Connection Header" propertyName="Connection"/>
        <remove-property doc:name="Remove Transfer-encoding Header" propertyName="transfer-encoding"/>
    </sub-flow>
    <sub-flow name="restore-soapaction">
        <set-property propertyName="soapaction" value="#[message.inboundProperties[&quot;soapaction&quot;]]" doc:name="Property"/>
    </sub-flow>
</mule>

So it works and proxing SOAP Envelop but everytime removes the xml declaration from response message body. For example when I send

<?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetActionInfo xmlns="http://concert.ru/InteropWS/">
      <actionId>53463</actionId>
    </GetActionInfo>
  </soap:Body>
</soap:Envelope>

with Headers SOAPAction: "http://concert.ru/InteropWS/GetActionInfo" to http://localhost:8077 I have

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
    <GetActionInfoResponse xmlns="http://concert.ru/InteropWS/">
        <GetActionInfoResult>
            <RowNum>0</RowNum>
            <Id>53463</Id>
            <Artist>PIRATE STATION LOVE                         MOSCOW</Artist>
            <Visible>true</Visible>
            <Canceled>0</Canceled>
            <AllowPrint>true</AllowPrint>
            <ETicketEnabled>1</ETicketEnabled>
            <TETicketEnabled>1</TETicketEnabled>
            <AgeRestrictionsId>5</AgeRestrictionsId>
            <ActionPlaceID>1321</ActionPlaceID>
            <ActionPlaceName>Stadium-live</ActionPlaceName>
            <CounterAgentId>1515</CounterAgentId>
            <CounterAgentName>Росдэнс ООО</CounterAgentName>
            <ActionTypeID>7</ActionTypeID>
            <DateList>
                <dateTime>2015-10-17T22:00:00</dateTime>
            </DateList>
            <DescriptionFull>Пиратская Станция "Love". Москва&lt;br/>17 октября, 22:00&lt;br/>Stadium Live&lt;br/>Москва, Ленинградский пр-т, д.80 корп.17&lt;br/>18+&lt;br/>&lt;br/>Крупнейший drum&amp;bass-фестиваль планеты от Радио Рекорд — Пиратская Станция — представит в Москве свою 13-ю постановку под названием "Love".&lt;br/>&lt;br/>Вслед за грандиозной премьерой в Санкт-Петербурге постановка "Love" расскажет трагическую историю любви по мотивам произведения "Ромео и Джульетта" Уильяма Шекспира под сеты ведущих drum&amp;bass-диджеев планеты.&lt;br/>&lt;br/&gt;Пиратская Станция "Love" — это потрясающее размахом театрально-цирковое шоу на земле и в воздухе, завораживающие спецэффекты, удивительные костюмы, внушительные декорации и фирменный череп в наушниках в центре постановки — неизменный символ фестиваля.&lt;br/>&lt;br/>&lt;b>Категории билетов:&lt;br/>Dancefloor&lt;/b> — доступ на танцпол, в Вашем распоряжении будут все бары на арене, ресторан и гардероб, а если Вы придете раньше, то займете место перед сценой ближе всех к необыкновенному шоу&lt;br/>&lt;b>Deluxe&lt;/b> — все привилегии Dancefloor, отдельный вход и гардероб, вход на эксклюзивный VIP-балкон с замечательным видом на сцену, отдельные бары&lt;br/>&lt;b>Gold&lt;/b> — все привилегии Gold, место за столиком на одном из ярусов каскадной части VIP-балкона с премиальным видом на сцену и индивидуальным обслуживанием официантами, отдельный вход и гардероб&lt;br/>&lt;b>Ложа&lt;/b> — персональный вход и сопровождение хостесс, панорамный вид на сцену и мероприятие в целом, персональное обслуживание официантами, алкогольные и безалкогольные напитки, фрукты и снэки, одно парковочное место&lt;br/></DescriptionFull>
        <Description>Пиратская Станция "Love". Москва&lt;br/>17 октября, 22:00&lt;br/>Stadium Live&lt;br/>Москва, Ленинградский</Description>
    <Coordinates>м.Сокол, Ленинградский проспект д.80 стр.17</Coordinates>
    <ActionTypeName>Клубы</ActionTypeName>
    <GenreTypeName>Электронная музыка</GenreTypeName>
    <CityName>Москва</CityName>
    <Latitude>55.808025</Latitude>
    <Longitude>37.510773</Longitude>
</GetActionInfoResult>
</GetActionInfoResponse></soap:Body></soap:Envelope>

However in the log message(last in the flow) I can see xml declaration in the payload.

How can I configure mule not to remove the xml declaration from response?

1

1 Answers

0
votes

You can add the missing data to the header using the following tag

<set-payload value="#['&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;']#[payload]" doc:name="Set Payload"/>

This works for me and I have tested this using the below code.

 <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8082" doc:name="HTTP Listener Configuration"/>
<flow name="testFlow1" >
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <set-payload value="#['&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;']#[payload]" doc:name="Set Payload"/>
    <logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>

Let me know if this helps