문제

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')            
                }
             }
        }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top