0

I am experiencing an issue within my In Sequnce of the following proxy :

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="AckServiceAPIProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="json-xml" value="text/xml" scope="axis2" type="STRING"/>
         <log level="full" category="DEBUG" separator="____:____"/>
         <property xmlns:ns="http://org.apache.synapse/xsd"
                   name="name"
                   expression="//productSearch/productName/text()"
                   scope="default"
                   type="STRING"/>
         <property xmlns:ns="http://org.apache.synapse/xsd"
                   name="size"
                   expression="//productSearch/productSize/text()"
                   scope="default"
                   type="STRING"/>
         <property xmlns:ns="http://org.apache.synapse/xsd"
                   name="colour"
                   expression="//productSearch/productColour/text()"
                   scope="default"
                   type="STRING"/>
         <payloadFactory media-type="xml">
            <format>
               <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
                              xmlns:ack="http://ack.pepkor.org">
                  <soap:Header/>
                  <soap:Body>
                     <ack:productSearch>
                        <ack:productName>$1</ack:productName>
                        <ack:productSize>$2</ack:productSize>
                        <ack:productColour>$3</ack:productColour>
                     </ack:productSearch>
                  </soap:Body>
               </soap:Envelope>
            </format>
            <args>
               <arg xmlns:ns="http://org.apache.synapse/xsd"
                    expression="$ctx:name"
                    evaluator="xml"/>
               <arg xmlns:ns="http://org.apache.synapse/xsd"
                    expression="$ctx:size"
                    evaluator="xml"/>
               <arg xmlns:ns="http://org.apache.synapse/xsd"
                    expression="$ctx:colour"
                    evaluator="xml"/>
            </args>
         </payloadFactory>
         <log level="full" category="DEBUG" separator="____:____"/>
         <send>
            <endpoint key="conf:/ackServiceEpr"/>
         </send>
      </inSequence>
      <outSequence>
         <log level="full" category="DEBUG" separator="____:____"/>
         <property name="messageType"
                   value="application/json"
                   scope="axis2"
                   type="STRING"/>
         <log level="full" category="DEBUG" separator="____:____"/>
         <send/>
      </outSequence>
      <faultSequence/>
   </target>
   <description/>
</proxy>

The REST request :

{ "productSearch":
    {   "productName":      "nike_shirts" ,
        "productSize":      "7",
        "productColour":    "red" 
    }
}

Let me break down the log :

    TID: [0] [ESB] [2015-02-03 11:56:14,994] DEBUG {org.apache.synapse.commons.json.JsonStreamBuilder} -  #processDocument. Built JSON payload from JSON stream. MessageID: urn:uuid:0d62c4ad-01b5-4eb5-ae7e-3b3aee762fbf {org.apache.synapse.commons.json.JsonStreamBuilder}

...

    #mediate. Transformed payload format>>> 
<pfPadding>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ack="http://ack.pepkor.org"><soap:Header></soap:Header><soap:Body><ack:productSearch><ack:productName>nike_shirts</ack:productName><ack:productSize>7</ack:productSize><ack:productColour>red</ack:productColour></ack:productSearch></soap:Body></soap:Envelope></pfPadding>

So I would expect the above message to be sent to the Ack Service (on Application Server) , however , INSIDE the SEND mediator , it then tranforms the original request payload(REST) again , and instead sends this to the service :

<productSearch><productName>nike_shirts</productName><productSize>7</productSize><productColour>red</productColour></productSearch>

The service call fails because of no namespaces , and brings back a fault.

The send mediator full log :

Start : Send mediator {org.apache.synapse.mediators.builtin.SendMediator}
TID: [0] [ESB] [2015-02-03 12:08:34,896] DEBUG {org.apache.synapse.endpoints.EndpointContext} -  Checking if endpoint : AnonymousEndpoint currently at state ACTIVE can be used now? {org.apache.synapse.endpoints.EndpointContext}
TID: [0] [ESB] [2015-02-03 12:08:34,896] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} -  Sending message through endpoint : null resolving to address = https://localhost:9444/services/ProductSearchACKService.ProductSearchACKServiceHttpsSoap12Endpoint/ {org.apache.synapse.endpoints.AddressEndpoint}
TID: [0] [ESB] [2015-02-03 12:08:34,896] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} -  SOAPAction: null {org.apache.synapse.endpoints.AddressEndpoint}
TID: [0] [ESB] [2015-02-03 12:08:34,897] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} -  WSA-Action: null {org.apache.synapse.endpoints.AddressEndpoint}
TID: [0] [ESB] [2015-02-03 12:08:34,897] DEBUG {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient} -  Sending [add = false] [sec = false] [rm = false] [mtom = false] [swa = false] [format = null] [force soap11=false] [force soap12=false] [pox=false] [get=false] [encoding=null] [to=https://localhost:9444/services/ProductSearchACKService.ProductSearchACKServiceHttpsSoap12Endpoint/] {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient}
TID: [0] [ESB] [2015-02-03 12:08:34,898] DEBUG {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient} -  Message [Original Request Message ID : urn:uuid:a451c7d8-b5a9-4474-8bd3-af9a25b65933] [New Cloned Request Message ID : urn:uuid:b0540f15-2094-4c3e-9184-fdc2df2fd491] {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient}
TID: [0] [ESB] [2015-02-03 12:08:34,898] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  Callback added. Total callbacks waiting for : 1 {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2015-02-03 12:08:34,900] DEBUG {org.apache.synapse.commons.json.JsonUtil} -  #transformElement. Transformed OMElement. Result: <productSearch><productName>nike_shirts</productName><productSize>7</productSize><productColour>red</productColour></productSearch> {org.apache.synapse.commons.json.JsonUtil}
TID: [0] [ESB] [2015-02-03 12:08:34,901] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #XmlReaderDelegate. Setting XMLStreamReader: com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,902] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productSearch, new=productSearch {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,903] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productName, new=productName {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,903] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productName, new=productName {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,904] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productSize, new=productSize {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,904] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productSize, new=productSize {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,904] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productColour, new=productColour {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,905] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productColour, new=productColour {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,905] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} -  #getLocalName. old=productSearch, new=productSearch {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,905] DEBUG {org.apache.synapse.commons.json.JsonStreamFormatter} -  #writeTo. Wrote JSON payload to output stream. MessageID: urn:uuid:b0540f15-2094-4c3e-9184-fdc2df2fd491 {org.apache.synapse.commons.json.JsonStreamFormatter}
TID: [0] [ESB] [2015-02-03 12:08:34,906] DEBUG {org.apache.synapse.mediators.builtin.SendMediator} -  End : Send mediator

.

Community
  • 1
  • 1
MiddlewareManiac
  • 570
  • 4
  • 19

1 Answers1

1

Your proxy receive a JSON request and you don't specify anything for the output so, the ESB send a JSON request to your ack service (see log trace #writeTo. Wrote JSON payload to output stream. MessageID: urn:uuid:b0540f15-2094-4c3e-9184-fdc2df2fd491 {org.apache.synapse.commons.json.JsonStreamFormatter})

If you want to send a SOAP request, you can specify attribute format="soap11" in your endpoint def (ackServiceEpr) or add a property in your inSequence, before send :

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

Perhaps do you need to set the SOAPAction in this case, use header mediator. If you want to set a blank one :

<header name="Action" value="&quot;&quot;"/>

If your ack service need plain xml, use application/xml

Jean-Michel
  • 5,926
  • 1
  • 13
  • 19
  • I did add the property , it's the very 1st line on the InSequence Jean. – MiddlewareManiac Feb 04 '15 at 07:47
  • It seems the web service is recieving this message (via ESB) nike_shirts7red. And when I directly invoke the service using the same message , I get the same fault – MiddlewareManiac Feb 04 '15 at 07:51
  • if it' a real webservice waiting for a SOAP envelope, define the property messageType like I explain it in my answer and forget your property "json-xml" – Jean-Michel Feb 04 '15 at 07:58
  • Does the property name NEED to be "messageType" ? – MiddlewareManiac Feb 04 '15 at 08:27
  • value of the property named "messageType", in scope "axis2" is used by the ESB to find the message formatter to use when sending out the message (the value of this property, not another) – Jean-Michel Feb 04 '15 at 08:47