Chriz L

Chriz L

  • NA
  • 220
  • 50.8k

How to save SOAP Request in a file while receiving it

Apr 30 2020 2:19 AM
Hello, 
I need to log the SOAP Requests sent from a web service. How can I get a SOAP Request saved in an xml file for error handling? Here's the following example:
  1. using System.Web.Services;  
  2.   
  3. namespace TestWebService  
  4. {  
  5.     [WebService(Namespace = "http://tempuri.org/")]  
  6.     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
  7.     [System.ComponentModel.ToolboxItem(false)]  
  8.     public class Test : System.Web.Services.WebService  
  9.     {  
  10.   
  11.         [WebMethod]  
  12.         public string HelloWorld(int a, int b)  
  13.         {  
  14.             int c = a + b;  
  15.   
  16.             return "The result is: "+c;  
  17.         }  
  18.     }  
  19. }  
Request (needs to be saved to file):
  1. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">    
  2.    <soapenv:Header/>    
  3.    <soapenv:Body>    
  4.       <tem:HelloWorld>    
  5.          <tem:a>5</tem:a>    
  6.          <tem:b>3</tem:b>    
  7.       </tem:HelloWorld>    
  8.    </soapenv:Body>    
  9. </soapenv:Envelope>  
Any kind of help would be appreciated, thank you! 

Answers (3)