How to mock SOAP web service call with a SOAP message in MUnit 2.1.3?

Creating a test case with mocking of SOAP web service call using MUnit 2.1.3 in Mulesoft
Transform processor will not work if you are just providing the original response of SOAP service as mock response. So you need to you tweak little in order to make it work with Transform message processor.
Look at the following example.  The is the complete SOAP message taken from the original response.

<?xml version='1.0' encoding='windows-1252'?>
<body>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <m:getTokenWSResponse xmlns:m="http://example.net/example-services">
         <m:SessionResponse>
            <com:RequestStatus xmlns:com="http://example.net/security/common">0</com:RequestStatus>
            <com:RequestMessage xmlns:com="http://example.net/security/common">Success</com:RequestMessage>
            <sec:SSOSessionID xmlns:sec="http://example.net/security/token">K7f0f0f3-b8f9-4eec-8d1c-b13cd0f3d00b</sec:SSOSessionID>
         </m:SessionResponse>
      </m:getTokenWSResponse>
   </env:Body>
</env:Envelope>
</body>     

This need to be changes as below in order to make the transform processor to work.

<?xml version='1.0' encoding='windows-1252'?>
<body>
      <m:getTokenWSResponse xmlns:m="http://example.net/example-services">
         <m:SessionResponse>
            <com:RequestStatus xmlns:com="http://example.net/security/common">0</com:RequestStatus>
            <com:RequestMessage xmlns:com="http://example.net/security/common">Success</com:RequestMessage>
            <sec:SSOSessionID xmlns:sec="http://example.net/security/token">K7f0f0f3-b8f9-4eec-8d1c-b13cd0f3d00b</sec:SSOSessionID>
         </m:SessionResponse>
      </m:getTokenWSResponse>
</body>     

This above message should be your mock message. Soap envelope and headers need to be removed in order make transform task to work.
Thanks
Jayaraman Pancharathinam
28 Nov 2018
Keywords: Mulesoft, Mule 4, MUnit 2.1.3, Anypoint Studio, Mocking, SOAP web service call, Transform processor

Comments

  1. Very useful information for communications. We can visit that acoustic movable partition gives the worthful information to you.

    ReplyDelete
  2. Very useful information for communications. We can visit that gives the worthful information to you.
    movable partition

    ReplyDelete

Post a Comment

Popular posts from this blog

How to read xml file and set as mock response for an http web service call in MUnit 2.1.3 in Mule 4?

How to set headers before calling a sub-flow in MUnit 2.1.3 in Mule 4?