WSO2 ESB Overwrites ContentType Property

I am working on a WSO2 ESB Proxy service, which includes providing an internal RESTful service through a SOAP endpoint on an ESB. My RESTful service requires Content-type = "application / rdf + xml". I tried to set it using all 3 properties mentioned in the documentation: messageType, ContentType and CONTENT_TYPE. However, the Content-type request is still "application / xml".

Here is an excerpt from my sequence that calls the REST service:

<property xmlns:ns="http://org.apache.synapse/xsd" name="REST_URL_POSTFIX" value="/record/12345" scope="axis2" type="STRING"/> <property name="HTTP_METHOD" value="PUT" scope="axis2" type="STRING"/> <property name="messageType" value="application/rdf+xml" scope="axis2" type="STRING"/> <property name="ContentType" value="application/rdf+xml" scope="axis2" type="STRING"/> <property name="CONTENT_TYPE" value="application/rdf+xml" scope="axis2" type="STRING"/> <send> <endpoint name="CQ"> <address uri="http://my_url" format="pox"> </address> <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('username:password'))" scope="transport"/> <property name="OSLC-Core-Version" value="2.0" scope="transport"/> <property name="Accept" value="application/rdf+xml" scope="transport"/> </endpoint> </send> 

I tested it with TCPMon and no matter what Content-type property I use, the request still contains "application / xml".

Please advice.

+4
source share
4 answers

Can you try the WSO2 ESB 4.7.0 with the following configuration? Please note that I changed the address format from "smallpox" to "rest"

  <property xmlns:ns="http://org.apache.synapse/xsd" name="REST_URL_POSTFIX" value="/record/12345" scope="axis2" type="STRING"/> <property name="HTTP_METHOD" value="PUT" scope="axis2" type="STRING"/> <property name="messageType" value="application/rdf+xml" scope="axis2" type="STRING"/> <property name="ContentType" value="application/rdf+xml" scope="axis2" type="STRING"/> <property name="CONTENT_TYPE" value="application/rdf+xml" scope="axis2" type="STRING"/> <send> <endpoint name="CQ"> <address uri="http://my_url" format="rest"> </address> <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('username:password'))" scope="transport"/> <property name="OSLC-Core-Version" value="2.0" scope="transport"/> <property name="Accept" value="application/rdf+xml" scope="transport"/> </endpoint> </send> 

These are the HTTP headers sent now (taken from tcpmon)

 PUT /record/12345 HTTP/1.1 Cookie: region1_configure_menu=none; region3_registry_menu=none; region4_monitor_menu=none; region5_tools_menu=none; JSESSIONID=54D2911FCD5559C6B2F723E7C6FA9B44; requestedURI="../../carbon/service-mgt/index.jsp?region=region1&item=services_list_menu"; current-breadcrumb=manage_menu%2Cservices_menu%2Cservices_list_menu%23 Authorization: null OSLC-Core-Version: 2.0 Content-Type: application/rdf+xml Accept: application/rdf+xml Transfer-Encoding: chunked Host: www.foo.com:8080 Connection: Keep-Alive User-Agent: Synapse-PT-HttpComponents-NIO 
+5
source

In the configuration you connected, you specified the uri address format as "smallpox".

 <address uri="http://my_url" format="pox"> 

This will cause you to always get the content type as application / xml. Remove this attribute and try. It should be

 <address uri="http://my_url"> 

If you still see the problem, try switching to NHTTP transport, as suggested by RaviU. To do this, you can first create the axis2.xml file (ESB_HOME / repository / conf / axis2 / axis2.xml) as axis2_back.xml and then rename the axis2_nhttp.xml file (same location) as axis2.xml.

+1
source

Sometimes you need to enable these message formatting in the axis2.xml file before using them.

Check out this article. This may help if you have not done so already.
http://wso2.com/library/articles/axis2-configuration-part2-learning-axis2-xml#mf

0
source

Can you set the content type property as follows:

  <property name="Content-Type" value="application/rdf+xml" scope="transport"/> 

Remove other content type properties.

If you define it like this:

  [1]<property name="messageType" value="application/rdf+xml" scope="axis2" type="STRING"/> [2]<property name="ContentType" value="application/rdf+xml" scope="axis2" type="STRING"/> 

[1] to select messageformatter

[2] to select message builders

Change try like this

  <inSequence> <log level="custom"> <property name="in seq --------------of proxy" expression="$trp:Content-Type"/> </log> <property name="messageType" value="application/json" scope="axis2" type="STRING"/> <property name="Content-Type" value="application/json" scope="transport" type="STRING"/> <log level="custom"> <property name="in seq --------------of proxy" expression="$trp:Content-Type"/> </log> <send> <endpoint> <address uri="http://localhost:5555/com"/> </endpoint> </send> 
0
source

Source: https://habr.com/ru/post/1487066/


All Articles