WSO2 ESB覆盖ContentType属性

WSO2 ESB覆盖ContentType属性,wso2,wso2esb,Wso2,Wso2esb,我正在研究WSO2 ESB代理服务,它涉及通过ESB上的SOAP端点公开内部RESTful服务。 我的RESTful服务需要Content type=“application/rdf+xml”。我尝试使用文档中提到的所有3个属性设置它:messageType、ContentType和CONTENT\u TYPE。但是,请求内容类型仍然是“application/xml” 下面是我调用REST服务的序列的摘录: <property xmlns:ns="http://org.apache

我正在研究WSO2 ESB代理服务,它涉及通过ESB上的SOAP端点公开内部RESTful服务。 我的RESTful服务需要Content type=“application/rdf+xml”。我尝试使用文档中提到的所有3个属性设置它:messageType、ContentType和CONTENT\u TYPE。但是,请求内容类型仍然是“application/xml”

下面是我调用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="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>

我用TCPMon对它进行了测试,无论我使用什么内容类型属性,请求仍然包含“application/xml”


请注意。

有时,在使用axis2.xml中的消息格式化程序之前,必须先启用它们

看看这篇文章。如果您还没有这样做,可能会有所帮助。

在您附加的配置中,您已将地址uri的格式指定为“pox”


这就是为什么您总是将内容类型设置为application/xml。请删除此属性并重试。应该是

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


如果您仍然看到这个问题,那么尝试按照RaviU的建议切换到NHTTP传输。为此,您可以首先将axis2.xml(ESB_HOME/repository/conf/axis2/axis2.xml)备份为axis2_back.xml,然后将axis2_nhttp.xml文件(相同位置)重命名为axis2.xml

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

您可以使用以下配置尝试WSO2 ESB 4.7.0吗?请注意,我已将地址格式从“pox”更改为“rest”


我猜您正在使用ESB4.6.0。ESB4.6.0中有一个已知的bug,它总是将传出内容类型更改为application/xml。一个解决办法是切换到NHTTP交通工具。Chanaka/RaviU,我尝试了你的两个建议,但没有一个有效。当我删除“format='pox'”时,内容类型设置为“application/soap+xml”。我已经在使用NHTTP传输而不是PassThrough:Ratha,我刚刚尝试了您的建议,但TCPMon仍然显示“Content Type:application/xml;charset=UTF-8”。你能根据我的配置快速创建自己的代理并自己尝试吗?@AlexYakimovich;我提供了一个jSON的示例,在您的例子中,它是不同的消息类型。您需要在axis2.xml中添加特定的messageformatter,这很有效!事实上,仅将messageType属性设置为“application/rdf+xml”就足够了。谢谢大家!+1.
 [1]<property name="messageType" value="application/rdf+xml" scope="axis2" type="STRING"/>
   [2]<property name="ContentType" value="application/rdf+xml" scope="axis2" type="STRING"/>
 <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>
   <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>
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