WSO2 ESB:记录 RDF REST 服务的响应并将其转换回 SOAP [英] WSO2 ESB: log and convert response from the RDF REST service back to SOAP

查看:44
本文介绍了WSO2 ESB:记录 RDF REST 服务的响应并将其转换回 SOAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的公司开发 WSO2 ESB POC,这涉及通过 ESB 上的 SOAP 端点公开内部 RESTful 服务.我已经阅读了与 SOAP-REST 中介相关的所有主题和博客文章,但仍然找不到答案.我的 RESTful 服务返回application/rdf+xml"消息格式.这是我的顺序:

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>

我能够成功地将请求发送到 RESTful 服务.但是我的 OUT 序列无法处理application/rdf+xml"响应.日志显示以下错误:

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


两个问题:
1.在 Axis2 对其应用 SOAP 转换之前,如何记录从 REST 服务收到的实际响应?我的日志中介只生成空的 SOAP 信封.


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.如何从 RDF+XML 转换回 SOAP 格式?为此,我应该在 OUT 序列中使用 XSLT 介体吗?


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

感谢您的帮助!

推荐答案

我编写了一个简单的 Nodejs 服务,用于发送 RDF 格式的消息.这是我使用 Advanced Rest Client Chrome 扩展程序调用它时的样子.

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.

然后我在 ESB 4.5.1 中创建了一个代理服务.这是我的代理服务配置,

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>

然后我使用 tryIt 工具向此代理服务发送 XML 消息.我正在使用日志中介来记录传入的 XML 消息.

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.

在输出序列中,我再次使用日志中介,我可以看到 RDF 被记录在那里.

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

您试用的 ESB 版本是什么?

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

这篇关于WSO2 ESB:记录 RDF REST 服务的响应并将其转换回 SOAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆