Forum Discussion

aveo's avatar
aveo
New Contributor
15 years ago

Configure several response for Mock service

Hi every one!

First, i would like to apologize for my english ... You will see in this message, it's not my mother tong

Anyway, why i'm writing this post ?

I'm using soapUi for the first time. I'm trying to create a mock reponse to replace the response to a webservice. For the moment no prob.
Things are being messy to me when i'm trying to get diferent reponse accorded to an information in my request message.

I tried to use the discard xpath option but it's not working. And the same thing with Query Match.

Here my request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cff="http://schemas.datacontract.org/2010/08/Cff.Modeles.WebServices.CffHeader" xmlns:tem="http://tempuri.org/">
<soapenv:Header>
<h:CffHeader xmlns:h="http://schemas.datacontract.org/2010/08/Cff.Modeles.WebServices.CffHeader" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<h:ApplicationCliente>Domus</h:ApplicationCliente>
<h:Code>43199</h:Code>
<h:Utilisateur/>
<h:UtilisateurPrimaire i:nil="true"/>
<h:UtilisateurSecondaire/>
</h:CffHeader>
</soapenv:Header>
<soapenv:Body>
<LireClient xmlns="http://tempuri.org/">
<_IdContact>1</_IdContact>
<_IdPrescipteur>000069370</_IdPrescipteur>
</LireClient>
</soapenv:Body>
</soapenv:Envelope>


My Response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<LireClientResponse xmlns="http://tempuri.org/">
<LireClientResult xmlns:a="http://schemas.datacontract.org/2004/07/Cff.Modeles.WebServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:CodeRetour>true</a:CodeRetour>
<a:ListeMessageMetier/>
<a:Valeur xmlns:b="http://schemas.datacontract.org/2004/07/Cff.Modeles.Crm">
<b:Contact>
<b:Civilite>1</b:Civilite>
<b:DateNaissance>1984-07-24T00:00:00</b:DateNaissance>
<b:NomNaissance>Soap</b:NomNaissance>
<b:Prenom>Ui</b:Prenom>
</a:Valeur>
</LireClientResult>
</LireClientResponse>
</s:Body>
</s:Envelope>

I would accorded to the _IdContact, give a different response.
To do so, i have done the tuto on the soap ui page:

I tried xpath using this expression:
declare namespace s='http://tempuri.org/'
//s:LireClient[1]/s:_IdContact[1]

It's always gave me "xpath expression return a null"

I tried query match with the same and it's doing nothing.

If anyone have an idea of what happen it would realy help me !

Thanks a lot !

3 Replies

  • aveo's avatar
    aveo
    New Contributor
    I have redone everything and now it's working...

    Don't ask me what wasn't working, i'm not able to tell
  • aveo's avatar
    aveo
    New Contributor
    Well in fact i've got an other problem concerning another mockup service...

    I'm trying to add several response to a service and i got a problem.

    Here the request:

    <editicFlow xmlns="http://edition.webservice.web.process.newbusiness.sopra.com/">
    <serviceSessionDto xmlns="">
    <companyId>432</companyId>
    </serviceSessionDto>
    <zcrof xmlns="">00000051800</zcrof>
    <docId xmlns="">ZZ</docId>
    </editicFlow>


    I'm trying to select the zcrof value using xpath with this expression:
    declare namespace web='http://edition.webservice.web.process.newbusiness.sopra.com/'
    //web:zcrof


    It doesn't work.

    If i delete the xmlns="" in my zcrof tag it work... The problem is i can't modify my request, it's not my work...

    Anyone have a clue?

    I already try without success:
    declare namespace web=''
    //web:zcrof

    Or
    declare namespace empty=''
    declare namespace web='http://edition.webservice.web.process.newbusiness.sopra.com/'
    //web:editicFlow/empty:zcrof
  • Did it maybe have something to do with using namespaces in your xpath which were not set in the elements in your request?

    First I got the same failure because I used the following xpath: "//ns1:Name" whereas the element was like "<Name>j. doe</name>".
    The xpath had to be //Name and the exepected value of the query match was "j. doe".