0

我们正在尝试在 WSO2 ESB 上实现基本的 SOAP-to-REST 代理服务。我们的第 3 方 REST 服务接受以下格式的请求:

http://<MYURL>/simpleQuery/16783484?oslc.select=value1

问题是操作名称只有数字格式——在我们的例子中是“16783484”。payloadFactory 调解器不允许将 <16783484> 作为 XML 元素,因为 XML 规范限制只有数字的元素名称。

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <payloadFactory>
            <format>
               <16783484>
                  <oslc.select>$1</oslc.select>
               </16783484>
            </format>
            <args>
               <arg value="myvalue1"/>
            </args>
         </payloadFactory>
         <send>
            <endpoint>
               <address uri="http://<MYURL>/simpleQuery" format="get"/>
            </endpoint>
         </send>
         <drop/>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
</proxy>

如何克服?

感谢你的帮助!

4

2 回答 2

2

WSO2 支持团队提出了以下解决方案。谢谢桑达帕!

在这种情况下,您必须将端点格式设置为“休息”。如果是 GET 请求,您必须将“HTTP_METHOD”设置为 GET。请参考下面给出的示例。

例子:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="REST_URL_POSTFIX" value="/getSimpleQuote?symbol=IBM" scope="axis2" type="STRING"/>
         <property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
         <send>
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService/" format="rest"/>
            </endpoint>
         </send>
         <drop/>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
   <description></description>
</proxy>
于 2013-03-08T14:06:27.910 回答
0

尽管此评论不会为您提供解决方案,但我可以说这是一个坏主意 :-) 您可以尝试使用 XSLT 而不是 PayloadFactory 进行转换,但这可能会再次阻塞 XML 解析器。问题是 WSO2 产品使用的许多开源项目/库,您可能会在其他地方碰到会遵守规范。从长远来看,当您与其他外部工具/系统集成时,遵守规范将减少您的麻烦。是否可以更改您的休息服务,以便服务名称前面至少有一个下划线?

于 2013-03-01T05:04:59.827 回答