In the last post, we have seen that calling proxies send the proxy name as a payload to CommonPS as shown below.
<Payload>
<ProxyName>PS_A</ProxyName>
<AuditPayload>
<Date>2011-05-23</Date>
<Description>Audit Data</Description>
</AuditPayload>
</Payload>
This approach has a problem that we have to manually change the ProxyName element in the payload every time we rename the proxy service. To overcome this problem we can use the XQuery expression $inbound/@name to get the proxy name. This would give the proxy name in the following format.
ProxyService$<fully qualified path of project separated by $>
So in PS_A, modify the assign activity that is present in the request pipeline as shown below.
Using the expression $inbound/@name in the above payload will be converted into the following once it reaches the CommonPS.
<Payload>
<ProxyName name="ProxyService$TestConfigProject$PS_A"/>
<AuditPayload>
<Date>2011-05-23</Date>
<Description>Audit Data</Description>
</AuditPayload>
</Payload>
This triggers a change in the message flow of CommonPS as well. So modify the assign activity which is shown below with a new expression to get the proxy name.
Modify the expression in this assign activity to the following.
fn:tokenize($body/Payload/ProxyName/@name, ‘\$’)[last()]
Now deploy both of the OSB projects(TestConfigProject and Project_A) and run PS_A and PS_B once by setting the Flag value as ‘Y’ and once with value ‘N’. Observe that the auditing is happening only when the Flag value is set to ‘Y’ as observed in earlier scenario.
0 Responses to “Using XQuery expression to get the Proxy Service Name”