title: How test soap based application with mock?
body: <p>I have 2 web applications which have web services. Suppose application One have 3 web methods and application Second app have only 1 web method which can return different results. Also all webmethods from app One call web method in app Second.</p>
  
  <p><strong>The goal is creation integration test for application One.</strong></p>
  
  <p>I can create soapui tests for each webmethod in app One and also add mock of Second app. But when tests for each method executes in parallel I must "tell" to mock "now you return that data, but now thow an Exception". I need that mock be able to recognize when it receive request for Second app from 1,2 or 3 web method in app One. When I create request for app One I cannot control it sub-request to app Second. So to distinguish them I must (somehow) mark entire requst chain:</p>
  
  <pre><code>Request1 -&gt; App One (WebMethod1) -&gt; SubRequest1 -&gt; Mock
  </code></pre>
  
  <p>For example if I can add Http header in Request1 which also can be retranslated to SubRequest1 the Mock will analyze this header and return/throw what I want. But actually HttpHeader do not retranslated. I can add java code for this, but code only for test is not very good.</p>
  
  <p>Is there any approach or way to do that testing? This is simplified example, in real situation there are more that 2 communicated applications and more web methods.</p>
  
  <p><strong>IMPORTANT</strong></p>
  
  <p>This question is not about Unit tests or EasyMock, PowerMock and Mockito. These frameworks related to unit tests, but I want integration testing.</p>