On Fri, Jan 27, 2012 at 10:03 PM, Abid Khan <[email protected]> wrote:

> Hello all,
>
> I have tried all options, I do need to change the content-type to
> "text/xml". And I do neet a quick resolution to this.
>

Setting ContentType property works, at least in the recent releases (2.0,
2.1). This is how the Content-type header is set on outgoing messages (in
Axis2HttpRequest class):

httpRequest.setHeader(
                    HTTP.CONTENT_TYPE,
                    messageFormatter.getContentType(msgContext,
format, msgContext.getSoapAction()));

In your case messageFormatter will be set to the ApplicationXMLFormatter
(from Axis2). This formatter looks at the ContentType property to determine
the content type of the message. So if you have set the property it will
get picked up. Not sure how it used to work back in the days of Synapse 1.2.

Thanks,
Hiranya


>
> Can anyone please point me to right direction.
>
> Thanks in advance,
> Abid
>
>
>
>
>
> -----Original Message-----
> From: Abid Khan
> Sent: Tuesday, January 24, 2012 4:02 PM
> To: [email protected]
> Subject: RE: Help needed for endpoint level content type.
>
> Hello Sadeep,
>
> I tried this, and several others. It look either synapse or axis2 is
> completely ignoring those properties. No matter what I set I always get
> "application/xml".
>
> So there may be a bug somewhere or this is by design. The content type are
> always posted as "application/xml"
>
>
> -----Original Message-----
> From: Sadeep Jayasumana [mailto:[email protected]]
> Sent: Tuesday, January 24, 2012 11:23 AM
> To: [email protected]
> Subject: Re: Help needed for endpoint level content type.
>
> Hi,
>
> You can set these properties conditionally within your CBR logic. Please
> check whether it works for you.
>
> Eg:
> <proxy name="CBRProxy">
>    <target>
>        <inSequence>
>          <switch source="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="
> http://services.samples";>
>              <case regex="IBM">
>                  <!-- Send with text/xml content type to endpoint 1 -->
>                  <property name="messageType" value="text/xml"
> scope="axis2"/>
>                  <property name="ContentType" value="text/xml"
> scope="axis2"/>
>                  <send>
>                      <endpoint>
>                          <address uri="http://localhost:9000/endpoint1"; />
>                      </endpoint>
>                  </send>
>              </case>
>              <case regex="MSFT">
>                  <!-- Send with application/xml content type to endpoint 2
> -->
>                  <property name="messageType" value="application/xml"
> scope="axis2"/>
>                  <property name="ContentType" value="application/xml"
> scope="axis2"/>
>                  <send>
>                      <endpoint>
>                          <address uri="http://localhost:9000/endpoint2"; />
>                      </endpoint>
>                  </send>
>              </case>
>           </switch>
>       </inSequence>
>   </target>
> </proxy>
>
> Thanks,
> Sadeep
>
> On Tue, Jan 24, 2012 at 9:14 PM, Abid Khan <[email protected]> wrote:
>
> > Hello Sadeep,
> >
> > Thanks for the quicker response.
> >
> > I actually knew this approach, but my problem is multiple application
> send
> > request to same proxy. That same proxy is delivering message (using
> content
> > based routing) to different endpoints.
> >
> > One of those endpoint expects "Content-Type=text/xml", where as rest of
> > them expect "Content-Type=application/xml".
> >
> > Having said that I need something in the endpoint not in the proxy.
> >
> > Thanks,
> > Abid
> >
> >
> >
> > -----Original Message-----
> > From: Sadeep Jayasumana [mailto:[email protected]]
> > Sent: Tuesday, January 24, 2012 12:52 AM
> > To: [email protected]
> > Subject: Re: Help needed for endpoint level content type.
> >
> > Hi,
> >
> > You can force the content type while sending a message out using
> > "messageType" and "ContentType" Axis2 level properties. Please check
> > whether this works for your scenario. This might not work if the message
> > content is not compatible with the formatter associated to the content
> type
> > you are forcibly setting.
> >
> >     ..
> >     ..
> >     <property name="messageType" value="text/xml" scope="axis2"/>
> >     <property name="ContentType" value="text/xml" scope="axis2"/>
> >     <send>
> >        <endpoint>
> >            <address uri="http://localhost:9000/endpoint1"; />
> >        </endpoint>
> >     </send>
> >
> > AND
> >
> >     ..
> >     ..
> >     <property name="messageType" value="application/xml" scope="axis2"/>
> >     <property name="ContentType" value="application/xml" scope="axis2"/>
> >     <send>
> >        <endpoint>
> >            <address uri="http://localhost:9000/endpoint2"; />
> >        </endpoint>
> >     </send>
> >
> > Thanks,
> > Sadeep
> >
> > On Tue, Jan 24, 2012 at 9:47 AM, Hiranya Jayathilaka
> > <[email protected]>wrote:
> >
> > > I believe these endpoints are being invoked through some proxy service.
> > If
> > > so what is the content type of the requests sent to the proxy service?
> > >
> > > Thanks,
> > > Hiranya
> > >
> > > On Tue, Jan 24, 2012 at 7:03 AM, Abid Khan <[email protected]>
> > wrote:
> > >
> > > > Hello all,
> > > >
> > > > Please help me in following scenario. (I am using synapse 1.2)
> > > >
> > > > I have two different endpoint, the application on one endpoint
> accepts
> > > > "Content-Type=application/xml", and second application on the other
> > > > endpoint accepts "Content-Type=text/xml".
> > > >
> > > > Those application are external application and are running for
> several
> > > > years, is there any way I can configure Synapse to send content type
> > > > properly to their respective endpoint.
> > > >
> > > > A prompt response will be much appreciated.
> > > >
> > > > Regards,
> > > > Abid
> > > >
> > >
> > >
> > >
> > > --
> > > Hiranya Jayathilaka
> > > Associate Technical Lead;
> > > WSO2 Inc.;  http://wso2.org
> > > E-mail: [email protected];  Mobile: +94 77 633 3491
> > > Blog: http://techfeast-hiranya.blogspot.com
> > >
> >
> >
> >
> > --
> >
> > Sadeep Jayasumana****
> >
> > Email: [email protected]****
> >
> > Phone: +94-77-2266507
> >
>
>
>
> --
>
> Sadeep Jayasumana****
>
> Email: [email protected]****
>
> Phone: +94-77-2266507
>



-- 
Hiranya Jayathilaka
Associate Technical Lead;
WSO2 Inc.;  http://wso2.org
E-mail: [email protected];  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Reply via email to