1

请帮忙,我对 groovy 的标记生成器有疑问。

针对端点 MYENDPOINT 和操作 MYACTION 的 WORKING SOAP 请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:SPECIAL">
   <soapenv:Header>
      <urn:xsdInfo>
         <urn:schemaLocation>SCHEMALOCATION</urn:schemaLocation>
      </urn:xsdInfo>
      <urn:category>Data Tables</urn:category>
      <urn:userInfo>
         <urn:sessionId>XXXXX</urn:sessionId>
      </urn:userInfo>
   </soapenv:Header>
   <soapenv:Body>
      <urn:add>
         <urn:DataTables urn:table_name="testtable">
            <!--Zero or more repetitions:-->
            <urn:each_record>
               <urn:s1>Somedinputdata</urn:s1>
            </urn:each_record>
         </urn:DataTables>
      </urn:add>
   </soapenv:Body>
</soapenv:Envelope>

尝试使用作为 wslite SOAP-Client 对象中的一个闭包的 makrup 构建器来复制它是行不通的(关于命名空间问题,我认为:

 def bmClient = new SOAPClient('MYENDPOINT')
    def response = bmClient.send(SOAPAction:'MYACTION') {
        header{
              xsdInfo('xmlns':'urn:soap.bigmachines.com'){
                  schemaLocation('SCHEMALOCATION')
              }  
              category('Data Tables')
              userInfo(){
                  sessionId('XXXXX')
              }
        }
        body{
              add('xmlns':'urn:SPECIAL'){
              // PROBLEM IS HERE: should be urn:table_name but then it says urn is not defined as namespace..
                 DataTables('table_name':'testtable'){
                    each_record(){
                       s1('something')            
                    }
                 }
            }
        }
    }
    return response.addResponse.status.message.text()
}catch(e){
    println 'Problem in addToDataTable Session ID: '+e.printStackTrace()
 }
}

目前它说:

wslite.soap.SOAPFaultException: soapenv:INIT-ERR - The element category, is required in the header.

虽然指定了一个类别...我只是卡在这里,有人知道如何创建

<urn:DataTables urn:table_name="testtable">

在标记闭包内正确吗?

我认为这是问题所在,因为我有另一个 Web 服务在相同的逻辑上运行得非常漂亮,但其中没有......

如果有人可以提供帮助会很棒,我正在第二天工作......

4

1 回答 1

3

如果你想完全匹配结构,你应该urn使用 定义信封上的命名空间envelopeAttributes,并在嵌套项目上使用它,如下所示:

def response = bmClient.send(SOAPAction:'MYACTION') {
    envelopeAttributes ('xmlns:urn' : 'urn:SPECIAL')   // watch out for brackets here!
    header{
          'urn:xsdInfo'{
              'urn:schemaLocation'('SCHEMALOCATION')
          }  
          'urn:category'('Data Tables')
          'urn:userInfo' {
              'urn:sessionId'('XXXXX')
          }
    }
    body{
          'urn:add' {
             'urn:DataTables'('urn:table_name':'testtable'){
                'urn:each_record'{
                   'urn:s1'('something')            
                }
             }
        }
    }
}
于 2013-05-08T15:27:35.240 回答