groovy-wslite markupbuilder在肥皂客户端中修改了命名空间问题 [英] groovy-wslite markupbuilder weired namespacing issue in soap-client

查看:174
本文介绍了groovy-wslite markupbuilder在肥皂客户端中修改了命名空间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



针对端点MYENDPOINT和动作MYACTION:


的工作SOAP请求

请帮忙,我对groovy的markupbuilder有问题。

 < 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>数据表< / urn:category>
< urn:userInfo>
< urn:sessionId> XXXXX< / urn:sessionId>
< / urn:userInfo>
< / soapenv:Header>
< soapenv:Body>
< urn:add>
< urn:DataTables urn:table_name =testtable>
<! - 零次或多次重复: - >
< urn:each_record>
< urn:s1> Somedinputdata< / urn:s1>
< / urn:each_record>
< / urn:DataTables>
< / urn:add>
< / soapenv:Body>
< / soapenv:Envelope>

尝试用wslite SOAP-Client对象中的闭包构建器来复制它,确实不工作(关于我认为的命名空间问题:

  def bmClient = new SOAPClient('MYENDPOINT')
def response = bmClient.send(SOAPAction:'MYACTION'){
header {
xsdInfo('xmlns':'urn:soap.bigmachines.com'){
schemaLocation('SCHEMALOCATION')

类('数据表')
userInfo(){
sessionId('XXXXX')
}
}
body {
add('xmlns':'urn:SPECIAL'){
//问题在于:应该是urn:table_name,但它表示urn没有被定义为命名空间。
DataTables(' table_name':'testtable'){
each_record(){
s 1('something')
}
}
}
}
}
return response.addResponse.status.message.text()
} catch(e){
println'addToDataTable中的问题会话ID:'+ e.printStackTrace()
}
}

目前它说:

  wslite.soap.SOAPFaultException:soapenv :INIT-ERR  - 标题中需要元素类别。 

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

 < urn:DataTables urn:table_name =testtable> 

标记关闭正确吗?

我认为这是问题,因为我有另一个web服务运行quity相同的逻辑,但没有在它...



如果有人可以帮助,我正在第二天工作...

解决方案

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

  def response = bmClient.send(SOAPAction:'MYACTION'){
envelopeAttributes('xmlns:urn':'urn: SPECIAL')//注意括号在这里!
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')
}
}
}
}
}


please help, i have a problem with the markupbuilder with groovy.

WORKING SOAP REQUEST against endpoint MYENDPOINT and the action MYACTION:

<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>

Trying to replicate this with the makrup builder which is a closure within the wslite SOAP-Client object, does not work (regarding to namespacing issue i think:

 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()
 }
}

currently it says:

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

although there is a category specified... I am just stuck here, somebody knows how to create

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

within the markup closure properly?

I think this is the problem, because i have another webservice running quity pretty on the same logic, but there is no in it...

Would be great if someone could help with that, i am working the second day on it...

解决方案

If you want to match the structure exactly, you should define the urn namespace on the envelope using envelopeAttributes, and use it on the nested items like so:

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')            
                }
             }
        }
    }
}

这篇关于groovy-wslite markupbuilder在肥皂客户端中修改了命名空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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