简体   繁体   English

WSO2 ESB-如何为远程服务调用构建soapenv:Body

[英]WSO2 ESB - How to build soapenv:Body for remote service call

I have the WSDL file of the remote web service I need to call from a proxy service in the WSO2 ESB and would like to know if I need to construct the soap:Body's elements manually through XSLT/Enrich or there is a way to generate the soapenv:Body's contains from the WSDL and maybe replace '?' 我有需要从WSO2 ESB中的代理服务调用的远程Web服务的WSDL文件,并且想知道是否需要通过XSLT / Enrich手动构造soap:Body的元素,或者有一种方法可以生成soapenv:正文包含来自WSDL的内容,并可能替换为“?” for the values. 值。

For example, if you've used soapUI before you'll know that when you import a WSDL file in a project a soapenv:Envelope gets generated automatically with all the XML elements and question marks for their values. 例如,如果您使用过soapUI,那么您将知道在项目中导入WSDL文件时,会自动生成soapenv:Envelope以及所有XML元素和它们的值的问号。 Same goes for the TryIt tool in the WSO2 ESB. WSO2 ESB中的TryIt工具也是如此。

Here is an example of an auto-generated soapenv:Envelope in soapUI after importing WSDL: 这是导入WSDL之后在soapUI中自动生成的soapenv:Envelope的示例:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:abc="http://abc.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <abc:RegisterCandidate>
         <abc:NameFirst>?</abc:NameFirst>
         <abc:NameMiddle>?</abc:NameMiddle>
         <abc:NameLast>?</abc:NameLast>
         <abc:PhoneHome>?</abc:PhoneHome>
         <abc:EmailAddress>?</abc:EmailAddress>
         <abc:Address1>?</abc:Address1>
         <abc:Address2>?</abc:Address2>
         <abc:City>?</abc:City>
         <abc:State>?</abc:State>
         <abc:ZipCode>?</abc:ZipCode>
         <abc:Country>?</abc:Country>
      </abc:RegisterCandidate>
   </soapenv:Body>
</soapenv:Envelope>

Is this possible in the Proxy Service through any of the mediators available to read a WSDL and generate soapenv:Body with its XML tags (in the code above it would be abc:RegisterCandidate with its children)? 在代理服务中,是否可以通过任何可用于读取WSDL并使用其XML标记生成soapenv:Body的中介程序(在上面的代码中为abc:RegisterCandidate及其子对象)? I've done it with the use of the XSL templates, but it's manual and not very elegant. 我已经通过使用XSL模板来做到这一点,但是它是手动的,不是很优雅。

I've found a few articles/blogs online about writing proxy services in the WSO2 ESB that call remote web services and what the developers were doing in there was to insert the XML elements needed in the soapenv:Body with the use of XSL templates to have the correct/full SOAP message that is then sent (send mediator) to the remote web service server. 我在网上找到了几篇有关在WSO2 ESB中编写代理服务(称为远程Web服务)的文章/博客,开发人员在其中所做的工作是使用XSL模板将soapenv:Body中所需的XML元素插入其中。具有正确/完整的SOAP消息,然后将其发送(发送介体)到远程Web服务服务器。

Thank you. 谢谢。

There is no way to generate the soap body from the remote service's wsdl as in your requirement. 无法按照您的要求从远程服务的wsdl生成肥皂主体。 But there is an easier way than using xslt. 但是有比使用xslt更简单的方法。 That is to use the payload factory mediator . 那就是使用有效负载工厂调解器 You can define the payload and assign values using xpath as shown in the sample. 您可以定义有效负载并使用xpath分配值,如示例中所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM