使用MarkupBuilder的Groovy SOAP请求XML

时间:2017-03-01 05:42:43

标签: xml web-services soap groovy

我有以下soap请求尝试使用Groovy中的MarkupBuilder创建

npm rebuild node-sass

Butam低于服务器的响应

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SignRequest xmlns="http://www.tw.com/tsswitch">
      <InputType>string</InputType>
      <JobType>string</JobType>
      <OutputType>string</OutputType>
      <Document>base64Binary</Document>
      <SenderTag>string</SenderTag>
      <ReceiverTag>string</ReceiverTag>
      <NrOfItems>int</NrOfItems>
      <SignerIdentifier>string</SignerIdentifier>
      <AgreementIdentifier>string</AgreementIdentifier>
      <ClientData>string</ClientData>
    </SignRequest>
  </soap:Body>
</soap:Envelope>


builder.encoding = "UTF-8"
def xmlBody = builder.bind { 
  mkp.xmlDeclaration() 
  mkp.declareNamespace(xsd:("http://www.w3.org/2001/XMLSchema"),xsi:("http://www.w3.org/2001/XMLSchema-instance"),soap:("http://schemas.xmlsoap.org/soap/envelope/")) 
          'soap:Envelope'() { 
            "soap:Body" () {
              "SignRequest"(xmlns:"http://www.tw.com/tsswitch"){
                "InputType"(){'GENERIC'}
                "JobType"(){'CADESA'}
                "OutputType"(){'SMIME'}
                "Document"(){file.data}
                "SenderTag"(){'US'}
                "ReceiverTag"(){'US'}
                "NrOfItems"(){1}
                "SignerIdentifier"(){null}
                "AgreementIdentifier"(){null}
              }
            }
         }
      }

有人可以帮我修复Server was unable to read request. ---> There is an error in XML document (2, 400). ---> Input string was not in a correct format. 吗?

1 个答案:

答案 0 :(得分:0)

我能够找到自己的

def xmlBody = builder.bind { 
  mkp.xmlDeclaration() 
  mkp.declareNamespace(xsd:("http://www.w3.org/2001/XMLSchema"),xsi:("http://www.w3.org/2001/XMLSchema-instance"),soap:("http://schemas.xmlsoap.org/soap/envelope/")) 
          'soap:Envelope'() { 
            "soap:Body" () {
              "SignRequest"(xmlns:"http://www.tw.com/tsswitch"){
                "InputType"('GENERIC')
                "JobType"('CADESA')
                "OutputType"('SMIME')
                "Document"(file.data)
                "SenderTag"('US')
                "ReceiverTag"('US')
                "NrOfItems"(1)
                "SignerIdentifier"(null)
                "AgreementIdentifier"(null)
              }
            }
         }
      }