问题描述
有一个元素,在WSDL中定义为base64Binary
。我附加了ContentID为ref1
的文件,并将其添加到SOAP请求中,如下所示:
<docBytes><xop:Include href="cid:ref1" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></docBytes>
尝试发送时出现以下错误消息:
cvc-type.3.1.2:元素“ docBytes”是一种简单类型,因此它必须具有 没有元素信息项[孩子]
当我在标签之间粘贴base64编码的字符串时,它是有效的。
解决方法
是的,我有发送PDF的服务,并且我将文档作为base64字节数组存储在这样的属性中:
def docContent = new File("path/to/file")
def encodedDoc = docContent.bytes.encodeBase64().toString()
testRunner.testCase.setPropertyValue("encodedDoc",encodedDoc)
然后将其用于:
<docBytes>${#TestCase#encodedDoc}</docBytes>
在请求中。