WSO2 ESB: log and convert response from the RDF REST service back to SOAP

跟風遠走 提交于 2019-12-25 12:09:06

问题


I am working on the WSO2 ESB POC for my company, which involves exposing the internal RESTful service via SOAP endpoint on the ESB. I've read all the threads and blog posts related to the SOAP-REST mediation, but still could not find an answer. My RESTful service returns "application/rdf+xml" message format. Here is my sequence:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <send>
            <endpoint>
               <address uri="http://<MYURL>/cqweb/oslc/repo/eraprototype/db/CQT_T/simpleQuery/16783484?oslc.select=dcterms:title,cq:CM_Label,dcterms:type,cq:Assigned_To,oslc_cm:status,cq:AutoDeployment,cq:SentToEADS_By&oslc.where=oslc:shortTitle=CQT_T00000131" format="get"/>
               <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('user:password'))" scope="transport"/>
               <property name="OSLC-Core-Version" value="2.0" scope="transport"/>
               <property name="Accept" value="application/rdf+xml" scope="transport"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
   <publishWSDL key="gov:/services/cqproxy/CQProxy.wsdl">
      <resource location="CQProxy.xsd" key="gov:/services/cqproxy/CQProxy.xsd"/>
      <resource location="eads_ws.xsd" key="gov:/services/eads_ws/eads_ws.xsd"/>
   </publishWSDL>
   <description></description>
</proxy>

I am able to send the request to the RESTful service successfully. However my OUT sequence can't process the "application/rdf+xml" response. Logs show the following error:

INFO {org.apache.axis2.builder.BuilderUtil} -  OMException in getSOAPBuilder {org.apache.axis2.builder.BuilderUtil}
org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found RDF


Two questions:
1. How can I log the actual response that is received from the REST service before Axis2 applies SOAP transformation to it? My log mediator generates empty SOAP envelope only.

INFO {org.apache.synapse.mediators.builtin.LogMediator} -  To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:4c06fcb9-4e45-4fb3-bc5a-4350e3d86533, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}


2. How do I convert from RDF+XML back to the SOAP format? Should I use XSLT mediator in the OUT sequence for this?

Appreciate your help!


回答1:


I wrote a simple Nodejs service that sends an RDF formatted message. Here's what it looks like when I invoke it using Advanced Rest Client Chrome extension.

Then I created a proxy service in ESB 4.5.1. Here's my proxy service configuration,

<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <log level="full"/>
         <send>
            <endpoint>
               <address uri="http://localhost:8080/" format="pox"/>
            </endpoint>
         </send>
         <log level="full"/>
         <drop/>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
   <description></description>
</proxy>

Then I used the tryIt tool to send an XML message to this proxy service. I'm using the log mediator to log the incoming XML message.

In the out sequence I'm using the log mediator again and I can see the RDF getting logged there.

What's the ESB version you're trying out this with?



来源:https://stackoverflow.com/questions/15010453/wso2-esb-log-and-convert-response-from-the-rdf-rest-service-back-to-soap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!