Hi,
I'm having trouble accessing a node value, I keep getting null returned. I'm using the free version of SoapUI to prove what we need to do can be done, but I'm having trouble getting it to work.
The groovy script below is for a Mockservice. I'm trying to access a value from the request and send back a response based on a node value.
The XML Request is:
<soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:soapenc="
http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<wsse:Security xmlns:wsse="
http://schemas.xmlsoap.org/ws/2002/07/secext" soap:mustUnderstand="0">
<wsse:UsernameToken>
<wsse:Username>ccmsUser</wsse:Username>
<wsse:Password Type="wsse:passwordText">ccmsPassword</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<ProcessingInstructions xmlns="
http://website.com/interfaces">
<IncludeEmptyElements>Y</IncludeEmptyElements>
</ProcessingInstructions>
</soap:Header>
<soap:Body>
<FaCSIAEnrolmentInterface_QueryEnrolments_Input xmlns="
http://website.com/interfaces">
<EndDateEmpty xsi:nil="1"/>
<ServiceProviderEnrolmentReference>2</ServiceProviderEnrolmentReference>
<PageNumber>1</PageNumber>
<Status xsi:nil="1"/>
<StartDateFrom xsi:nil="1"/>
<EndDateFrom xsi:nil="1"/>
<PageSize>10</PageSize>
<SourceSystemCode>1-I6TS</SourceSystemCode>
<Type xsi:nil="1"/>
<CCBApprovalId>232432</CCBApprovalId>
<StartDateTo xsi:nil="1"/>
<EndDateTo xsi:nil="1"/>
<FACSIAEnrolmentId xsi:nil="1"/>
<TransactionId>27E1460B-A5B9-4082-9968-235AAE728C22</TransactionId>
<UpdatedSince xsi:nil="1"/>
</FaCSIAEnrolmentInterface_QueryEnrolments_Input>
</soap:Body>
</soap:Envelope>
My groovy script is:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( mockRequest.requestContent )
//return holder.getNodeValue( "//wsse:Username" )
return holder.getNodeValue( "//ServiceProviderEnrolmentReference" )
def sper = holder.getNodeValue( "//ServiceProviderEnrolmentReference" )
if (sper == "1")
return "Response 1"
else if (sper == "2")
return "Response 2"
else
return "Response 1"
The line return holder.getNodeValue( "//wsse:Username" ) works and returns a response. But holder.getNodeValue( "//ServiceProviderEnrolmentReference" ) returns null. If I change the node to anything contained within the <soap:body> tags I get null.
Can you tell me what I'm doing wrong?
Thanks,
Adam