使用 Robot Framework 中的 SUDS 库创建带有 objectTypes 的 Soap 消息 [英] Creating Soap messages with objectTypes using SUDS library in Robot Framework

查看:31
本文介绍了使用 Robot Framework 中的 SUDS 库创建带有 objectTypes 的 Soap 消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用带有 SUDS 库的机器人框架创建肥皂消息的这一部分.

i am struggling to create this part of the soap message using robot framework with SUDS library.

<ns1:Request>
    <ns0:ID objectType="SomeType">Value</ns0:ID>
</ns1:Request>

如果我喜欢这个,那么我会得到我需要的所有东西,但不会得到 objectType.

If i do like this, then i get all i need but not the objectType.

${object}=    Create Wsdl Object    ns19:RequestTypeSingle
Set Wsdl Object Attribute    ${object}    ID    1234

输出

  <ns1:Request>
    <ns0:ID>1234</ns0:ID>
  </ns1:Request>

如果我检查我的 ns19:RequestTypeSingle 想要什么,我会得到这个:

If i check what my ns19:RequestTypeSingle wants i get this:

${object} = (RequestTypeSingle){
   ID = 
      (ID){
         _objectType = ""
      }
 }

RequestTypeSingle"定义

"RequestTypeSingle" definition

<xs:complexType name="RequestTypeSingle">
 <xs:sequence>
  <xs:element minOccurs="1" maxOccurs="1" name="ID" nillable="true">
   <xs:complexType>
    <xs:simpleContent>
     <xs:extension base="xs:string">
      <xs:attribute name="objectType" type="xs:string"/>
     </xs:extension>
    </xs:simpleContent>
   </xs:complexType>
  </xs:element>
 </xs:sequence>
</xs:complexType>

那么我如何用 SUDS 或其他一些声明这个 "(ID){_objectType = ""}?

So how can i declare this "(ID){_objectType = ""} with SUDS or some other?

感谢 ombre42,这可以做到(回答第一个问题):

Thanks to ombre42 this can be done like this (first question answered):

${req}=    Create WSDL Object    ns19:RequestTypeSingle    # may need namespace prefix here
Set Wsdl Object Attribute    ${req.ID}    _objectType    SomeType

(继续提问).这将如何设置我在请求示例中提到的值.看起来这种语法会起作用,但它没有.关于这个有什么好主意吗?

(Continuing question). How ever this will not set the value as i mentioned in my request example. It would seem that this kind of syntax would work but it did not. Any great ideas on this one?

这将给出错误:ValueError: Object must be a WSDL object (suds.sudsobject.Object)."

This will give an error: "ValueError: Object must be a WSDL object (suds.sudsobject.Object)."

${req}=    Create WSDL Object    ns19:RequestTypeSingle    # may need namespace prefix here
Set Wsdl Object Attribute    ${req}    ID    1234
Set Wsdl Object Attribute    ${req.ID}    _objectType    SomeType

这将覆盖第一个 _objectType 定义.

And this will overwrite the first _objectType definition.

${req}=    Create WSDL Object    ns19:RequestTypeSingle    # may need namespace prefix here
Set Wsdl Object Attribute    ${req.ID}    _objectType    SomeType
Set Wsdl Object Attribute    ${req}    ID    1234

我所说的覆盖是指我得到这个:

What i mean by overwrite is that i get this:

  <ns1:Request>
    <ns0:ID>1234</ns0:ID>
  </ns1:Request>

推荐答案

当将值分配给表示为 XML 属性而不是元素的属性时,请在名称前加上下划线(为什么使用 _objectType 而不是 objectType).

When assigning a value to property that is expressed as an XML attribute instead of an element, prefix the name with an underscore (why _objectType instead of objectType).

${req}=    Create WSDL Object    RequestTypeSingle    # may need namespace prefix here
Set Wsdl Object Attribute    ${req.ID}    _objectType    SomeType

这篇关于使用 Robot Framework 中的 SUDS 库创建带有 objectTypes 的 Soap 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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