Contributions
Can I update a mock service WSDL?
I think I am missing something here, but the WSDL has been changed and I would like to be able to reuse my responses and scripting I created last time around. The changes are minimal to the WSDL, mostly ordering but this client app is very particular about that. Seems like I can only add new mock service? I added the WSDL to the project but it did not update the Mock Service. Thanks! -Tim722Views0likes0CommentsRe: [SOLVED] Help with the 'groovyUtils.getXmlHolder'
Well; I think my issue is with the declaration of a default namespace, rather than a prefix for each individual tag. http://www.w3schools.com/XML/xml_namespaces.asp scroll down to default namespaces Again, a sample below of the request being read in... <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <RunScript xmlns="http://tempuri.org/"> <optionObject> <EntityID>5</EntityID> <Facility>98</Facility> <Forms> <FormObject.... //more </Forms> </RunScript> Can holder.getNodeValue work here without a ns prefix??? It seems strange that it wouldn't just pick it up. I can see the entire request when write out the xmlObject to the log. I have already tried to include the 'path' (wrong term I know) within the xml such as... context.EntityID = holder.getNodeValue( "//RunScript/optionObject/EntityID") ...and every combination of the proceeding I can find, but still not able to read in node value(s). I also have tried declaring the default ns in the script it in various ways but I am just guessing because I have not seen any examples without a prefix. But that didn't seem logical anyway because i wasn't using any prefixes, which I think is the point when declaring in the script. Is this a bug? Thanks again. -Tim12KViews0likes0CommentsRe: getNodeValue is not passing the value from XPath to variable
Might either of you have suggestions for reading properties from a request formatted like this? This is the way it comes from the client.... I cannot alter it (other than the ns name). <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <RunScript xmlns="http://tempuri.org/"> <optionObject> <EntityID>5</EntityID> <Facility>98</Facility> <Forms>..... Currently I have this which returns null... def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def holder = groovyUtils.getXmlHolder( mockRequest.requestContent ) context.EntityID = holder.getNodeValue( "//EntityID") context.EntityID = holder.getNodeValue( "//Facility") Any help is greatly appreciated... -Tim MODIFIED POST Thanks to M McDonald for the solution to my issue above, I needed to declare a 'temp' ns above for use in the script. def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( xml ) holder.declareNamespace( 'ns', 'http://tempuri.org/') //add this declaration log.info holder.getNodeValue( "//ns:Facility") //add 'ns' prefix log.info holder.getNodeValue( "//ns:EntityID")1.8KViews0likes0Comments[SOLVED] Help with the 'groovyUtils.getXmlHolder'
I am using soapUI mock service to test a client calling from a DB (Intersystems Cache), and I can't seem to read properties into my dispatch script (I also am using them in the response) from the xml holder. I am thinking it has something to do with the format of the incoming request, but i cannot seem to make the XML holder read in the values from my live client WS. This request, generated from soapUI works fine... <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> <soapenv:Header/> <soapenv:Body> <tem:RunScript> <!--Optional:--> <tem:optionObject> <tem:EntityID>5</tem:EntityID> <tem:Facility>98</tem:Facility> <Forms> <FormObject.... I am able to assign properties with the following code..... def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( mockRequest.requestContent ) context.Facility = holder.getNodeValue( "//tem:Facility") context.EntityID = holder.getNodeValue( "//tem:EntityID") However when I get the following request from my client (or the same format when sent from soapUI)... <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <RunScript xmlns="http://tempuri.org/"> <optionObject> <EntityID>5</EntityID> <Facility>98</Facility> <Forms> <FormObject.... I cannot assign any values if the script is written as follows..... def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( mockRequest.requestContent ) context.Facility = holder.getNodeValue( "//Facility") context.EntityID = holder.getNodeValue( "//EntityID") I also notice that this request is read in 'flat' meaning that when I view the request detail from the mock service editor it looks like this....(note the !CDATA[string]] at the end) <?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:s='http://www.w3.org/2001/XMLSchema'> <SOAP-ENV:Body> <RunScript xmlns="http://tempuri.org/"><optionObject><EntityID>5</EntityID><Facility>98</Facility><Forms><FormObject><CurrentRow><Fields><FieldObject><FieldNumber>2</FieldNumber><FieldValue><![CDATA[ROSS,JOE]]>.... </SOAP-ENV:Envelope> ...While the first sample from above appears as formatted XML when viewed in the same pane. Any ideas how I can read in properties if my requests are arriving like this??? Any help is greatly appreciated!! -Tim18KViews0likes5CommentsRe: Help with Mock Responses
Ah yes, I had looked a that help topic, however I did not notice that "Invalid Session Id Fault" was one of the defined responses, since it is cut off in the screen shot.... That does help! I can now execute a dispatch, sort of. I did not have success with the statement however. I do not believe I am obtaining values from the request properly... My new code.. def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def holder = groovyUtils.getXmlHolder( mockRequest.requestContent ) def scriptName = holder.getNodeValue( "//scriptName") def optionId = holder.getNodeValue( "//OptionId") if (scriptName == "TEST2") return "Response2" else return "error" always returns the "error" response, so at least I know it is being executed! They are nested within objects, do I need to add their hierarchy? some thing like... (//RunScript/scriptName) The request is... (scriptName and OpionId tags near bottom) <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> <soapenv:Header/> <soapenv:Body> <tem:RunScript> <!--Optional:--> <tem:optionObject> <!--Optional:--> <tem:ErrorMesg> </tem:ErrorMesg> <tem:ErrorCode> </tem:ErrorCode> <!--Optional:--> <tem:Forms> <!--Zero or more repetitions:--> <tem:FormObject> <!--Optional:--> <tem:CurrentRow> <!--Optional:--> <tem:Fields> <!--Zero or more repetitions:--> <tem:FieldObject> <!--Optional:--> <tem:FieldNumber>FIELD1</tem:FieldNumber> <!--Optional:--> <tem:FieldValue>XXXXXXXX</tem:FieldValue> <!--Optional:--> <tem:Required>0</tem:Required> <!--Optional:--> <tem:Enabled>1</tem:Enabled> <!--Optional:--> <tem:Lock> </tem:Lock> </tem:FieldObject> </tem:Fields> <!--Optional:--> <tem:ParentRowId>0</tem:ParentRowId> <!--Optional:--> <tem:RowId>ROW1</tem:RowId> </tem:CurrentRow> <!--Optional:--> <tem:FormId>FORMID1</tem:FormId> <tem:MultipleIteration>0</tem:MultipleIteration> <!--Optional:--> <tem:OtherRows> <!--Zero or more repetitions:--> <tem:RowObject> <!--Optional:--> <tem:Fields> <!--Zero or more repetitions:--> <tem:FieldObject> <!--Optional:--> <tem:FieldNumber> </tem:FieldNumber> <!--Optional:--> <tem:FieldValue> </tem:FieldValue> <!--Optional:--> <tem:Required> </tem:Required> <!--Optional:--> <tem:Enabled> </tem:Enabled> <!--Optional:--> <tem:Lock> </tem:Lock> </tem:FieldObject> </tem:Fields> <!--Optional:--> <tem:ParentRowId> </tem:ParentRowId> <!--Optional:--> <tem:RowId> </tem:RowId> </tem:RowObject> </tem:OtherRows> </tem:FormObject> </tem:Forms> <!--Optional:--> <tem:OptionId>OPTION2</tem:OptionId> <!--Optional:--> <tem:SystemCode>SYSTEM1</tem:SystemCode> <!--Optional:--> <tem:EntityID>OOOOOOO</tem:EntityID> <!--Optional:--> <tem:EpisodeNumber> </tem:EpisodeNumber> <tem:Facility>QQQQ</tem:Facility> <!--Optional:--> <tem:OptionUserId>ZZZZZZ</tem:OptionUserId> <!--Optional:--> <tem:OptionStaffId>YYYYYYY</tem:OptionStaffId> </tem:optionObject> <!--Optional:--> <tem:scriptName>TEST2</tem:scriptName> </tem:RunScript> </soapenv:Body> </soapenv:Envelope> Do scriptName and OptionId also need to be defined as properties somehwere? I figured i would have to do that in the MockResponse when it came time to modify the response, but I thought that would have been separate from the dispatch (I would have to read in from the xmlHolder again in the repsonse) More thanks... -Tim1.1KViews0likes0CommentsRe: Help with Mock Responses
I am working on the MockResponse dispatch and I think I have it right so far... def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def holder = groovyUtils.getXmlHolder( mockRequest.requestContent ) def scriptName = holder.getNodeValue( "//scriptName") def optionId = holder.getNodeValue( "//OptionId") if (scriptName == "TEST2") How do I now specify the MockResponse to use? And if i were to use multiple arguments in my if statement, what is the groovy syntax? I have searched the forum high and low. Thanks again... -Tim1.1KViews0likes0CommentsHelp with Mock Responses
Hi All; I have been using SoapUI for a bit over a year now, purely as a client to file/retrieve data to/from a db. I was simply editing/copying requests to manually build test suites. I now am charged with testing a WS client from my db against non existent services. I am able to manually mock up the responses, but now need to get a bit more dynamic in my responses. I need to able to do 2 things.... 1. Read a portion of the request (min 2 parameters, more in some cases) and use that to determine the mock response dispatch. 2. Return a portion of each request exactly as submitted. Based on a little lurking here, and reading the help doc, I am thinking that scripting would be the best way to achieve both objectives... Might someone be able to provide a simple example of each? Or possibly point to a tutorial(s). My presumption is that the dispatch scripting will take place in the 'Mock Operation Editor' and the defaulting behavior from request data will be scripted in the 'Mock Response Editor' I currently am using the free 3.0.1. I have very little coding experience, no groovy experience; but can alter once I get a simple working version of each. Thanks in advance, -Tim2.1KViews0likes4Comments