Domanda

Voglio usare il seguente XPath

.

/ utenti / utente / userid

Questo non funziona perché l'ESB aggiunge una busta di sapone e un corpo attorno al mio XML, qual è il corretto XPath da utilizzare o come posso rimuovere la busta e il corpo del sapone?

L'XML è:

.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <Users xmlns="http://ws.wso2.org/dataservice">
         <User>
            <UserID>a</UserID>
            <Username>a</Username>
            <Email>a</Email>
            <Password>a</Password>
         </User>
         <User>
            <UserID>a</UserID>
            <Username>a</Username>
            <Email>a</Email>
            <Password>a</Password>
         </User>
         <User>
            <UserID>a</UserID>
            <Username>a</Username>
            <Email>a</Email>
            <Password>a</Password>
         </User>
      </Users>
   </soapenv:Body>
</soapenv:Envelope>
.

Modifica:

Funziona quando provo a registrarlo al di fuori del mio Mediatore iterato

//*[local-name() = 'Users']/*[local-name() = 'User']/*[local-name() = 'UserID']
.

Ma quando provo a registrarlo all'interno del mediatore iterato non restituisce nulla?

È stato utile?

Soluzione

ha ottenuto questo lavoro usando il seguente

<property xmlns:int="http://ws.wso2.org/dataservice" name="uri.var.ID" expression="$body/int:User/int:UserID/text()" scope="default" type="STRING"/>
.

Altri suggerimenti

Per accedere ai tuoi elementi dovresti passare attraverso la busta e il corpo. Ecco un esempio con Switch Mediator:

<switch xmlns:ns="http://org.apache.synapse/xsd" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:int="http://ws.wso2.org/dataservice" 
        source="boolean(/soap:Envelope/soap:Body/int:Users/int:User/int:UserID/text() = 'string_to_compare'">
  <case regex="true">
     ....
  </case>
  <default/>
</switch>
.

UPD Espressione XPath corretta

Prova questo:

<property name="yourParamName" expression="$body/Users/User/UserID" scope="default" type="STRING"/>
.

Puoi leggere di più sulle variabili di sinapsi predefinite xpath qui .

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top