Edit Soap Request Payload

Not applicable

Hi,

In the request payload, I want to delete one entry . How can I achieve in assign message policy . should I construct the whole payload and assign it to request ?

Thanks,

Suma

Solved Solved
1 3 2,156
1 ACCEPTED SOLUTION

Hmmmm "delete one entry" - I am guessing you mean that

  • you have a request or response object
  • it contains a SOAP message in the content
  • you would like to delete an element in the SOAP message , and assign it back to the message.content

If that's the case, You can do it that with the built-in XSLT policy in Edge. Here is an example XSLT that removes an element. It looks like this:

<xsl:stylesheet version="1.0" 
  xmlns:ns1="urn:my-custom-namespace"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="ns1:NameOfElementToRemove"/>

</xsl:stylesheet>

Obvs in the above you need to replace NameOfElementToRemove with the correct name of the element you wish to remove. And, urn:my-custom-namespace with the namespace of the element.

Alternatively, there's a Java callout I've written that allows you to add or replace an XML node. It would be pretty simple to modify that callout to also allow you to remove one XML node. If you like I can show you that. Let me know.

Also it would help if you provided as an example the specific SOAP message and the specific element within the SOAP message that you would like to remove.

If i have misunderstood your question, please clarify what you mean by "delete one entry". Give lots of context, because... just reading the question, it can be difficult to understand what you intend.

View solution in original post

3 REPLIES 3

Hmmmm "delete one entry" - I am guessing you mean that

  • you have a request or response object
  • it contains a SOAP message in the content
  • you would like to delete an element in the SOAP message , and assign it back to the message.content

If that's the case, You can do it that with the built-in XSLT policy in Edge. Here is an example XSLT that removes an element. It looks like this:

<xsl:stylesheet version="1.0" 
  xmlns:ns1="urn:my-custom-namespace"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="ns1:NameOfElementToRemove"/>

</xsl:stylesheet>

Obvs in the above you need to replace NameOfElementToRemove with the correct name of the element you wish to remove. And, urn:my-custom-namespace with the namespace of the element.

Alternatively, there's a Java callout I've written that allows you to add or replace an XML node. It would be pretty simple to modify that callout to also allow you to remove one XML node. If you like I can show you that. Let me know.

Also it would help if you provided as an example the specific SOAP message and the specific element within the SOAP message that you would like to remove.

If i have misunderstood your question, please clarify what you mean by "delete one entry". Give lots of context, because... just reading the question, it can be difficult to understand what you intend.

Hi Dino,

I have a request object (Soap XML payload) . I would like to delete an element in the soap message and assign the modified request to request.content.

Below is the Soap request :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header>

<sf:SessionHeader>

<sf:sessionId></sf:sessionId>

<sf:serverUrl></sf:serverUrl>

</sf:SessionHeader>

</soapenv:Header>

<soapenv:Body> <ns1> <ns1> <ns1> <ns2> <ns2> <ns2> </ns1> </ns2> </soapenv:Body> </soapenv:Envelope>

Would like to remove <sf:serverUrl></sf:serverUrl> from the request payload.

Thanks, Suma

Hi Dino,

Thanks for xsl snippet. it worked .

Thanks,

Suma