SOAP-UI - 如何在参数中传递 xml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5715404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 14:39:54  来源:igfitidea点击:

SOAP-UI - How to pass xml inside parameter

xmlsoapui

提问by RedEagle

In SOAP-UI I am making a request to a web service like this:

在 SOAP-UI 中,我向这样的 Web 服务发出请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xxx="http://xxx.call/">
   <soapenv:Header/>
   <soapenv:Body>
      <cotf:call_XXX>
         <!--Optional:-->
         <arg0>
            <!--Optional:-->
            <parameter1>some text</parameter1>
            <!--Optional:-->
            <parameter2>XML string</parameter1>
         </arg0>
      </cotf:call_XXX>
   </soapenv:Body>
</soapenv:Envelope>

What I would like to know is how I can pass an XML string on parameter 2 since if I put the XML string directly it assumes the XML string nodes as request parameters....

我想知道的是如何在参数 2 上传递 XML 字符串,因为如果我直接放置 XML 字符串,它将假定 XML 字符串节点作为请求参数......

Thanks

谢谢

回答by Alin Purcaru

Either encode the needed XML entities or use CDATA.

编码所需的 XML 实体或使用 CDATA。

<arg0>
    <!--Optional:-->
    <parameter1>&lt;test>like this&lt;/test></parameter1>
    <!--Optional:-->
    <parameter2><![CDATA[<test>or like this</test>]]></parameter2>
 </arg0>

回答by bitsmonkey

NOTE: This one is just an alternative for the previous provided .NET framework 3.5 and above

注意:这只是之前提供的 .NET 框架 3.5 及更高版本的替代方案

You can send it as raw xml

您可以将其作为原始 xml 发送

<test>or like this</test>

If you declare the paramater2 as XElementdata type

如果将 paramater2 声明为XElement数据类型

回答by Randnum

To send CDATA in a request object use the SoapObject.setInnerText("...");method.

要在请求对象中发送 CDATA,请使用该SoapObject.setInnerText("...");方法。