You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Soumya <so...@yahoo.co.in> on 2010/11/08 18:01:38 UTC

Smix supports only XML?

Hi all,

I am stuck with a strange problem. similar to 

http://markmail.org/message/65dec77yvimv2xat#query:ServiceMix%20CDATA+page:1+mid:32vexgibvf4yjabu+state:results

I have a requirement where a Mobile App wants to send a Json request  as that is 
apparently faster to process than XML. What i did was exposed a simplistic 
webservice

<Request>

<![CDATA[
{
  "Username": "xyz",
  "Password": "xyz",

  "MyReq":   {
    "abc": "1332222053",
    "CCC": {"PPP": {"aaa": {"bbb": "rrrr"}}}
  }
}
 
 
]]>
</Request>

i.e wrapped the Json in CDATA in a xml request. The request is posted to a 
Servicemix 3.3.2 Http component which then forwards it to Smix 3.3.2 LWC 
component. In the Lwc receiver I then extract the JSON and work on it using 
Jsson utilities. In the response I am sending like
<Response>

<![CDATA[
{
 
 "Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}
 
 
]]>
</Response>

However after the exchange is sent - in teh client the CDATA section is striped 
off and what I receive is just <Response/>
I have logged the exchange.getContent and still it contains the CDATA section 
till then. So not to sure at what point it is getting lost. With Smix 3.2.1 it 
did strip off the "<![CDATA[" syntax but still had the content of the CDATA in 
the response like
<Response>


{
 
 "Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}
 
</Response>

Any clue as to why it behaves that way in Smix 3.3.2?


Also next question -
can't we paste a generic String or say a Json request object in Servicemix HTTP 
POST request at all? Is it like it only allows xml? I initially ahd tried to use 
plain Json string in the body of the POST but that failed during marshalling and 
rejected as invalid request.

Please if an expert can help I would eb greatful

Cheers,
Soumya


RE: Smix supports only XML?

Posted by Łukasz Dywicki <lu...@code-house.org>.
Most of ServiceMix endpoints allows to inject own Marshaler by attribute named 'marshaler':
http://servicemix.apache.org/servicemix-http-new-endpoints.html

You simply need to define bean in XML configuration and next inject them:
marshaler="#myMarshaler"

Best regards,
Lukasz



-----Original Message-----
From: Soumya [mailto:soumya_ssp@yahoo.co.in] 
Sent: Wednesday, November 10, 2010 5:29 PM
To: users@servicemix.apache.org
Subject: Re: Smix supports only XML?

Hi Lukasz,
Thanks for the pointer. So what I need to do is implement the 
HttpConsumerMarshaller interface and deploy it in the Http component zip and 
modify the xbean.xml some way?
Sorry to ask again but if you have any example I would be grateful.

Thanks a lot
Soumya




________________________________
From: Łukasz Dywicki <lu...@code-house.org>
To: users@servicemix.apache.org
Sent: Wed, 10 November, 2010 10:28:59 AM
Subject: RE: Smix supports only XML?

Hi,
Try to use custom marshaller with http endpoint and check what http component 
receives. Basically you're right, servicemix 3.x works with XML payloads so all 
requests have to be serializable to XML form. The marshaller [1] can receive 
plain JSON post data and wrap it to XML.

Best regards,
Lukasz

[1] 
http://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java


-----Original Message-----
From: Soumya [mailto:soumya_ssp@yahoo.co.in] 
Sent: Monday, November 08, 2010 6:02 PM
To: Servicemix group
Subject: Smix supports only XML?

Hi all,

I am stuck with a strange problem. similar to 

http://markmail.org/message/65dec77yvimv2xat#query:ServiceMix%20CDATA+page:1+mid:32vexgibvf4yjabu+state:results


I have a requirement where a Mobile App wants to send a Json request  as that is 

apparently faster to process than XML. What i did was exposed a simplistic 
webservice

<Request>

<![CDATA[
{
  "Username": "xyz",
  "Password": "xyz",

  "MyReq":   {
    "abc": "1332222053",
    "CCC": {"PPP": {"aaa": {"bbb": "rrrr"}}}
  }
}


]]>
</Request>

i.e wrapped the Json in CDATA in a xml request. The request is posted to a 
Servicemix 3.3.2 Http component which then forwards it to Smix 3.3.2 LWC 
component. In the Lwc receiver I then extract the JSON and work on it using 
Jsson utilities. In the response I am sending like
<Response>

<![CDATA[
{

"Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}


]]>
</Response>

However after the exchange is sent - in teh client the CDATA section is striped 
off and what I receive is just <Response/>
I have logged the exchange.getContent and still it contains the CDATA section 
till then. So not to sure at what point it is getting lost. With Smix 3.2.1 it 
did strip off the "<![CDATA[" syntax but still had the content of the CDATA in 
the response like
<Response>


{

"Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}

</Response>

Any clue as to why it behaves that way in Smix 3.3.2?


Also next question -
can't we paste a generic String or say a Json request object in Servicemix HTTP 
POST request at all? Is it like it only allows xml? I initially ahd tried to use 

plain Json string in the body of the POST but that failed during marshalling and 

rejected as invalid request.

Please if an expert can help I would eb greatful

Cheers,
Soumya



Re: Smix supports only XML?

Posted by Soumya <so...@yahoo.co.in>.
Hi Lukasz,
Thanks for the pointer. So what I need to do is implement the 
HttpConsumerMarshaller interface and deploy it in the Http component zip and 
modify the xbean.xml some way?
Sorry to ask again but if you have any example I would be grateful.

Thanks a lot
Soumya




________________________________
From: Łukasz Dywicki <lu...@code-house.org>
To: users@servicemix.apache.org
Sent: Wed, 10 November, 2010 10:28:59 AM
Subject: RE: Smix supports only XML?

Hi,
Try to use custom marshaller with http endpoint and check what http component 
receives. Basically you're right, servicemix 3.x works with XML payloads so all 
requests have to be serializable to XML form. The marshaller [1] can receive 
plain JSON post data and wrap it to XML.

Best regards,
Lukasz

[1] 
http://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java


-----Original Message-----
From: Soumya [mailto:soumya_ssp@yahoo.co.in] 
Sent: Monday, November 08, 2010 6:02 PM
To: Servicemix group
Subject: Smix supports only XML?

Hi all,

I am stuck with a strange problem. similar to 

http://markmail.org/message/65dec77yvimv2xat#query:ServiceMix%20CDATA+page:1+mid:32vexgibvf4yjabu+state:results


I have a requirement where a Mobile App wants to send a Json request  as that is 

apparently faster to process than XML. What i did was exposed a simplistic 
webservice

<Request>

<![CDATA[
{
  "Username": "xyz",
  "Password": "xyz",

  "MyReq":   {
    "abc": "1332222053",
    "CCC": {"PPP": {"aaa": {"bbb": "rrrr"}}}
  }
}


]]>
</Request>

i.e wrapped the Json in CDATA in a xml request. The request is posted to a 
Servicemix 3.3.2 Http component which then forwards it to Smix 3.3.2 LWC 
component. In the Lwc receiver I then extract the JSON and work on it using 
Jsson utilities. In the response I am sending like
<Response>

<![CDATA[
{

"Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}


]]>
</Response>

However after the exchange is sent - in teh client the CDATA section is striped 
off and what I receive is just <Response/>
I have logged the exchange.getContent and still it contains the CDATA section 
till then. So not to sure at what point it is getting lost. With Smix 3.2.1 it 
did strip off the "<![CDATA[" syntax but still had the content of the CDATA in 
the response like
<Response>


{

"Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}

</Response>

Any clue as to why it behaves that way in Smix 3.3.2?


Also next question -
can't we paste a generic String or say a Json request object in Servicemix HTTP 
POST request at all? Is it like it only allows xml? I initially ahd tried to use 

plain Json string in the body of the POST but that failed during marshalling and 

rejected as invalid request.

Please if an expert can help I would eb greatful

Cheers,
Soumya


RE: Smix supports only XML?

Posted by Łukasz Dywicki <lu...@code-house.org>.
Hi,
Try to use custom marshaller with http endpoint and check what http component receives. Basically you're right, servicemix 3.x works with XML payloads so all requests have to be serializable to XML form. The marshaller [1] can receive plain JSON post data and wrap it to XML.

Best regards,
Lukasz

[1] http://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java

-----Original Message-----
From: Soumya [mailto:soumya_ssp@yahoo.co.in] 
Sent: Monday, November 08, 2010 6:02 PM
To: Servicemix group
Subject: Smix supports only XML?

Hi all,

I am stuck with a strange problem. similar to 

http://markmail.org/message/65dec77yvimv2xat#query:ServiceMix%20CDATA+page:1+mid:32vexgibvf4yjabu+state:results

I have a requirement where a Mobile App wants to send a Json request  as that is 
apparently faster to process than XML. What i did was exposed a simplistic 
webservice

<Request>

<![CDATA[
{
  "Username": "xyz",
  "Password": "xyz",

  "MyReq":   {
    "abc": "1332222053",
    "CCC": {"PPP": {"aaa": {"bbb": "rrrr"}}}
  }
}
 
 
]]>
</Request>

i.e wrapped the Json in CDATA in a xml request. The request is posted to a 
Servicemix 3.3.2 Http component which then forwards it to Smix 3.3.2 LWC 
component. In the Lwc receiver I then extract the JSON and work on it using 
Jsson utilities. In the response I am sending like
<Response>

<![CDATA[
{
 
 "Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}
 
 
]]>
</Response>

However after the exchange is sent - in teh client the CDATA section is striped 
off and what I receive is just <Response/>
I have logged the exchange.getContent and still it contains the CDATA section 
till then. So not to sure at what point it is getting lost. With Smix 3.2.1 it 
did strip off the "<![CDATA[" syntax but still had the content of the CDATA in 
the response like
<Response>


{
 
 "Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}
 
</Response>

Any clue as to why it behaves that way in Smix 3.3.2?


Also next question -
can't we paste a generic String or say a Json request object in Servicemix HTTP 
POST request at all? Is it like it only allows xml? I initially ahd tried to use 
plain Json string in the body of the POST but that failed during marshalling and 
rejected as invalid request.

Please if an expert can help I would eb greatful

Cheers,
Soumya



Re: Smix supports only XML?

Posted by Soumya <so...@yahoo.co.in>.
Hello all,
Can someone kindly help me with the questions below?

Cheers,
Soumya





________________________________
From: Soumya <so...@yahoo.co.in>
To: Servicemix group <us...@servicemix.apache.org>
Sent: Mon, 8 November, 2010 5:01:38 PM
Subject: Smix supports only XML?

Hi all,

I am stuck with a strange problem. similar to 

http://markmail.org/message/65dec77yvimv2xat#query:ServiceMix%20CDATA+page:1+mid:32vexgibvf4yjabu+state:results


I have a requirement where a Mobile App wants to send a Json request  as that is 

apparently faster to process than XML. What i did was exposed a simplistic 
webservice

<Request>

<![CDATA[
{
  "Username": "xyz",
  "Password": "xyz",

  "MyReq":   {
    "abc": "1332222053",
    "CCC": {"PPP": {"aaa": {"bbb": "rrrr"}}}
  }
}


]]>
</Request>

i.e wrapped the Json in CDATA in a xml request. The request is posted to a 
Servicemix 3.3.2 Http component which then forwards it to Smix 3.3.2 LWC 
component. In the Lwc receiver I then extract the JSON and work on it using 
Jsson utilities. In the response I am sending like
<Response>

<![CDATA[
{

"Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}


]]>
</Response>

However after the exchange is sent - in teh client the CDATA section is striped 
off and what I receive is just <Response/>
I have logged the exchange.getContent and still it contains the CDATA section 
till then. So not to sure at what point it is getting lost. With Smix 3.2.1 it 
did strip off the "<![CDATA[" syntax but still had the content of the CDATA in 
the response like
<Response>


{

"Status":   { 
    "code": "001",
    "Msg": "SUCCESS"
  }
}

</Response>

Any clue as to why it behaves that way in Smix 3.3.2?


Also next question -
can't we paste a generic String or say a Json request object in Servicemix HTTP 
POST request at all? Is it like it only allows xml? I initially ahd tried to use 

plain Json string in the body of the POST but that failed during marshalling and 

rejected as invalid request.

Please if an expert can help I would eb greatful

Cheers,
Soumya