如何使用groovy在soapUi中的所有请求中添加自定义安全标记

如何使用groovy在soapUi中的所有请求中添加自定义安全标记,soap,groovy,automation,soapui,Soap,Groovy,Automation,Soapui,我必须在头中的所有请求中插入安全标签。如何实现自动化?因为对于每个请求,我必须手动复制过去,这需要时间来完成所有请求 以下是实际请求: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.test.sample.com/" xmlns:ws1="http://ws.test.sample.

我必须在头中的所有请求中插入安全标签。如何实现自动化?因为对于每个请求,我必须手动复制过去,这需要时间来完成所有请求

以下是实际请求:

   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.test.sample.com/" xmlns:ws1="http://ws.test.sample.com/">         
    <soapenv:Header>
    </soapenv:Header>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:ws="http://ws.test.sample.com/" xmlns:ws1="http://ws.test.sample.com/">  
    <soapenv:Header>
          <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://doc.test.xsd">
           <wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://doc.test.xsd">
           <wsse:Username>test</wsse:Username>
           <wsse:Password Type="http://doc.test.xsd">o9j1/hA/mkFTG0ODti</wsse:Password>
          </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>

添加安全标签后:

   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.test.sample.com/" xmlns:ws1="http://ws.test.sample.com/">         
    <soapenv:Header>
    </soapenv:Header>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:ws="http://ws.test.sample.com/" xmlns:ws1="http://ws.test.sample.com/">  
    <soapenv:Header>
          <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://doc.test.xsd">
           <wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://doc.test.xsd">
           <wsse:Username>test</wsse:Username>
           <wsse:Password Type="http://doc.test.xsd">o9j1/hA/mkFTG0ODti</wsse:Password>
          </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>

测试
o9j1/hA/mkFTG0ODti

hi@daggett你能解释一下吗。我已经浏览了上面的链接,但无法跟进。你必须解释你想做什么。最好将您迄今为止尝试过的代码共享。我想象的情况是:读取soapui项目XML并在每个请求中添加安全头。因此,我在下面的步骤中分享了如何操作XML.Hi@daggett的链接。1.项目->WS-Security配置->传出安全配置2.添加新WSS->选中必须理解复选框3.添加新WSS条目->添加用户名和pwd以及pwd类型密码文本。在Soap请求中,右键单击并选择OUTGOING WSS security,然后选择创建的安全性。上面的工作正常,安全标签在应用后根据请求成功添加,并且也收到了res。问题是,当我使用groovy自动化时,安全标签会自动添加吗?或者怎么做