2013-05-06 98 views
1

請幫助,我與groovy標記構建器的問題。groovy-wslite markupbuilder在肥皂客戶端weired命名空間問題

WORKING對端點MYENDPOINT SOAP請求和行動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> 

正在嘗試與makrup建設者這是wslite SOAP客戶端對象內的封閉複製此,不工作(關於向命名空間問題我想:

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"> 
標記關閉正常範圍內

,我認爲這是問題,因爲我有運行quity漂亮的同一邏輯另一web服務,但沒有在它...

將是巨大的,如果有人可以提供幫助的,我工作它第二天...

+0

你解決方案完美無缺謝謝sooooo多! – Booyeoo 2013-05-08 16:30:59

回答

3

如果你想的結構完全匹配,你應該定義使用envelopeAttributes信封urn命名空間,並使用它的嵌套項目,像這樣:

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