Hello all,

Please look at the following code and tell me why this code is explicitly 
changing contentType from "text/xml" to "application/xml"?

This issue is because this kind of code in ApplicationXMLFormatter,

      if (contentType == null) {
          contentType = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
      } else if (isSOAPContentType(contentType)) {
          contentType = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
          if (log.isDebugEnabled()) {
              log.debug("contentType is set incorrectly for Application XML.");
              log.debug("It is changed to " + contentType);
          }
      }

Along with function in


   private boolean isSOAPContentType(String contentType) {
       if (JavaUtils.indexOfIgnoreCase(contentType, 
SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
           return true;
       }
       // search for "type=text/xml"
       else if (JavaUtils.indexOfIgnoreCase(contentType,
                                            
SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
           return true;
       }
       return false;
   }

This code is explicitly changing the content type to "application/xml" if it is 
"text/xml"

I would like to know if changing this code would have any negative impacts.

Regards,
Abid

-----Original Message-----
From: Abid Khan 
Sent: Friday, January 27, 2012 9:34 AM
To: '[email protected]'
Subject: RE: Help needed for endpoint level content type.

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.

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

Reply via email to